25
32

More than 5 years have passed since last update.

VSCodeの設定ファイル(launch.json, settings.json, tasks.json等)の中身を全部羅列してみた

Last updated at Posted at 2019-03-31

この記事はなんなのか

以前,VSCodeのセットアップ・各種言語(C,C++,Python,LaTex)の環境構築のまとめ(というかVSCode布教サイト)というVSCode環境構築記事を書きましたが,記事の中でsettings.jsonとかtasks.jsonの中身には詳しく触れなかったので,それの補足記事です.
上の記事を書く上で自分の環境でバグった時の環境設定の対策が分からない事が多々あり,多分そういう人が他にもいると思いました.
そこで皆さんが適宜欲しい所(なんなら全部)をコピペして動くようになればいいなと思い,現在動いている環境設定を載せました.
上の記事を更新したら適宜こちらも更新する予定です.
ただ,VSCodeは[基本設定]→[設定]からチェックを入れて設定できる項目もあり,そっちまでは流石に網羅できませんでした(数が多すぎ).すみません.ただ,基本的には上の記事に載せてあるサイトの通りに設定はしています.
もし「ここら辺で上手く動かないんだけど,設定どうしてる?」というのがあったらコメント等に投げてください.分かれば対応したいと思います.

launch.json

VSCodeにおいてプログラムをデバックするときに役立つファイル.
ただ,launch.json内の右下に出る[構成の追加...]を押せば勝手に各環境の構成してくれるし,なんならデバックする時に[F5]を押すと自動で構成してくれるので,デバックオプションを付けたい人だけ書く感じ.
(因みにcpp単体ではデバックできないので,以下の文は多分役に立たない.訳も分からず筆者が足搔いていた頃の軌跡です...でも"type"の部分をやりたい言語にすれば動くのでそうやって使って.)

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${file}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}

settings.json

色んな環境の設定を決めるファイル.「チェックを入れて設定できる項目」は大体ここなので,検索して出てくるものについては書くよりチェックを入れると無難かも.
(***は自分のユーザー名を入れてね)

settings.json
{
    //CPP設定
    "files.associations": {
        "xstring": "cpp"    , "fstream": "cpp"      ,
        "xlocale": "cpp"    , "cstdlib": "cpp"      ,
        "cmath": "cpp"      , "cstddef": "cpp"      ,
        "cstdint": "cpp"    , "cstdio": "cpp"       ,
        "cstring": "cpp"    , "cwchar": "cpp"       ,
        "exception": "cpp"  , "initializer_list": "cpp" ,
        "ios": "cpp"        , "iosfwd": "cpp"       ,
        "iostream": "cpp"   , "istream": "cpp"      ,
        "limits": "cpp"     , "memory": "cpp"       ,
        "new": "cpp"        , "ostream": "cpp"      ,
        "stdexcept": "cpp"  , "streambuf": "cpp"    ,
        "string": "cpp"     , "system_error": "cpp" ,
        "tuple": "cpp"      , "type_traits": "cpp"  ,
        "typeinfo": "cpp"   , "utility": "cpp"      ,
        "xfacet": "cpp"     , "xiosbase": "cpp"     ,
        "xlocinfo": "cpp"   , "xlocnum": "cpp"      ,
        "xmemory": "cpp"    , "xmemory0": "cpp"     ,
        "xstddef": "cpp"    , "xtr1common": "cpp"   ,
        "xutility": "cpp"
    },
    "C_Cpp.errorSquiggles": "Disabled",
    //Python設定
    "python.jediEnabled": false,
    "python.pythonPath": "C:\\Users\\***\\AppData\\Local\\Programs\\Python\\Python37\\python.exe",
    "python.linting.pylintEnabled": true,
    "files.autoGuessEncoding": true,
    //Latex設定
    "latex-workshop.latex.recipes": [
        {
            "name": "ptex2pdf",
            "tools": [
                "ptex2pdf",//タイプセットに使うtoolの名前
            ]
        }
    ],
    "latex-workshop.latex.tools": [{//タイプセットに使うtoolの設定
        "name": "ptex2pdf",
        "command": "ptex2pdf",
        "args": [
            "-l",
            "-ot",
            "-kanji=utf8 -synctex=1",
            "%DOC%"
        ]
    }],
}

tasks.json

ビルド時の設定を書くファイル.正直書かなくても死にはしない.
でもここを上手く設定すると,cppなどのファイルをビルドする時に一発でコンパイル&実行出来るようになったりする.
でも「Coderunner」ってプラグインを入れるとそんな必要はなくなります.マジ有能.

tasks.json
{
    "version": "2.0.0",
    "tasks": [
        //Python設定
        {
            "label": "Python",
            "command": "python",
            "type": "process",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

c_cpp_properties.json

cppの設定をするファイル.以下のファイルが最も簡潔で,最低限これだけあれば動く,はず.
自信のない人は,以下(自信のない人用)のように,合ってそうなパスを全部ぶち込むことをお勧めする.

c_cpp_properties.json(簡潔)
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:\\\\MinGW"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64"
        }
    ],
    "version": 4
}
c_cpp_propaties.json(自信がない人用)
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                 "${workspaceRoot}",
                 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                 "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward",
                 "C:/MinGW/lib/gcc/mingw32/6.3.0/include",
                 "C:/MinGW/include",
                 "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode":"clang-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include",
                    "C:/MinGW/include",
                    "C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ]
}
25
32
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
32