插件
C/C++ IntelliSense :代码提示*
Chinese (Simplified) Language Pack for Visual Studio Code :中文界面*
CMAKE
CMake Tools
F5
-启动调试,选择C++c_cpp_properties.json
{
"configurations": [
{
"name": "CMake",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "/usr/bin/g++", // 根据自己的安装目录确定
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64", // 注意修改, 提供智能提示
"configurationProvider": "vector-of-bool.cmake-tools"
}
],
"version": 4
}
cmake_minimum_required(VERSION 3.0.0)
project(cc_test VERSION 0.1.0)
aux_source_directory(. DIR_TOOT_SRCS)
# debug 模式
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
add_executable(cc_test ${DIR_TOOT_SRCS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}
{
"tasks": [
{
"type": "shell",
"label": "cmake build active file", // 任务名称
"command": "cmake --build ${workspaceFolder}/build --config Debug --target all -- -j 10", // cmake指令
"args": [
], // 指令参数
"options": {
"cwd": "/usr/bin"
}
}
],
"version": "2.0.0"
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // default: g++.exe build and debug active file
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/cc_test", // 可执行文件所在的路径, cc_test= 替换成自己的项
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true, // 显示独立控制台窗口
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "cmake build active file" // 执行cmake编译任务, 再task.json中定义的
}
]
}
一键分号;
keybindings.json
[
{
"key": "ctrl+;",
"command": "macros.end_semicolon"
},
]
settings.json
{"macros": {
"end_semicolon": [ // 末尾加分号
"cursorLineEnd",
{
"command": "type",
"args": {
"text": ";"
}
},
],
}
}
原文:https://www.cnblogs.com/haoge2000/p/14113446.html