VScode配置
huangyihe114514 · · 算法·理论
首先,vscode下载链接:vscode。 然后,我们打开 vscode,创建一个文件夹:.vscode。在这里面,我们需要放四个配置文件:
- c_cpp_properties.json:
{ "configurations": [ { "name": "Win64", "includePath": ["${workspaceFolder}/**"], "defines": ["_DEBUG", "UNICODE", "_UNICODE"], "windowsSdkVersion": "10.0.18362.0", "compilerPath": "E:/MinGW/bin/g++.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4 } - launch.json:
{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "fileDirname{fileDirname}\\fileDirname{fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "E:/MinGW/bin/gdb.exe", "preLaunchTask": "g++", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
3. settings.json:
```json
{
"files.associations": {
"*.py": "python",
"iostream": "cpp",
"*.tcc": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"ostream": "cpp",
"new": "cpp",
"typeinfo": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"fstream": "cpp",
"sstream": "cpp",
"map": "c",
"stdio.h": "c",
"algorithm": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"ios": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"memory": "cpp",
"random": "cpp",
"set": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"stdlib.h": "c",
"string.h": "c",
"any": "cpp",
"array": "cpp",
"barrier": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cuchar": "cpp",
"cwctype": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_set": "cpp",
"expected": "cpp",
"functional": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ratio": "cpp",
"regex": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"format": "cpp",
"future": "cpp",
"iomanip": "cpp",
"latch": "cpp",
"mutex": "cpp",
"numbers": "cpp",
"ranges": "cpp",
"scoped_allocator": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"spanstream": "cpp",
"stacktrace": "cpp",
"stdfloat": "cpp",
"stop_token": "cpp",
"syncstream": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"valarray": "cpp",
"variant": "cpp",
"cfloat": "cpp"
},
"editor.suggest.snippetsPreventQuickSuggestions": false,
"aiXcoder.showTrayIcon": true,
"C_Cpp.errorSquiggles": "disabled"
}
- tasks.json:
{ "version": "2.0.0", "tasks": [ { "label": "g++", "command": "g++", "args": [ "-g", "${file}", "-o", "fileDirname/{fileDirname}/fileDirname/{fileBasenameNoExtension}.exe" ], "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "${workspaceRoot}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } }, "group": "build" }, { "type": "cppbuild", "label": "C/C++: g++.exe 生成活动文件", "command": "E:/MinGW/bin/g++.exe", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "fileDirname{fileDirname}\\fileDirname{fileBasenameNoExtension}.exe" ], "options": { "cwd": "E:/MinGW/bin" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true }, "detail": "调试器生成的任务。" } ] }请把这四个文件中的路径名改为 MinGW 的 bin 的路径名,并将反斜杠改为除号。
接下来,我们需要下载几个必要的插件:
- C/C++
- C/C++ Compile Run
- Code Runner
- Chinese (Simplified) (简体中文) Language Pack for VScode 然后我们就可以开始愉快地 coding 了!
当然,作为一名 OIer,仅有这些是不够的。所以我们可以再下一个 Competitive Programming Helper (cph),这样我们的 VScode 就可以像 CP Editor 一样好用了!