- c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
- launch.json
{
// 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",
"type": "cppdbg", //正在使用的調(diào)試器,使用Visual Studio Windows時必須為cppvsdbg,使用GDB或LLDB時必須為cppdbg.
"request": "launch", //表示此配置是用于啟動程序還是附加到已運行的實例上
"program": "${fileDirname}/${fileBasenameNoExtension}", //要執(zhí)行的可執(zhí)行文件的完整路徑
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}", //設置調(diào)試器啟動的應用程序的工作目錄
"environment": [],
"externalConsole": false, // 是否啟用外部的終端,wsl下建議用false
"MIMode": "gdb", //要連接的調(diào)試器
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build" // 這里要跟task.json里面的label一致
}
]
}
- task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "build",
"command": "g++",
"args": [
"-g",
"${workspaceFolder}/${fileBasename}",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
// 還有什么編譯選項在這里添加
],
"group": "build",
"presentation": {
// Reveal the output only if unrecognized errors occur.
"reveal": "silent"
},
// Use the standard MS compiler pattern to detect errors, warnings and infos
"problemMatcher": []
}
]
}
- .clang-format
通??捎孟旅婷顏砩?,style選項 LLVM 、Google 、Chromium 、 Mozilla 、 Microsoft 、 GNU文章來源:http://www.zghlxwxcb.cn/news/detail-686600.html
clang-format -style=LLVM -dump-config > .clang-format文章來源地址http://www.zghlxwxcb.cn/news/detail-686600.html
# 語言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto
Language: Cpp
# BasedOnStyle: LLVM
# 訪問說明符(public、private等)的偏移
AccessModifierOffset: -4
# 開括號(開圓括號、開尖括號、開方括號)后的對齊: Align, DontAlign, AlwaysBreak(總是在開括號后換行)
AlignAfterOpenBracket: Align
# 連續(xù)賦值時,對齊所有等號
AlignConsecutiveAssignments: false
# 連續(xù)聲明時,對齊所有聲明的變量名
AlignConsecutiveDeclarations: false
# 右對齊逃脫換行(使用反斜杠換行)的反斜杠
AlignEscapedNewlines: Right
# 水平對齊二元和三元表達式的操作數(shù)
AlignOperands: true
# 對齊連續(xù)的尾隨的注釋
AlignTrailingComments: true
# 不允許函數(shù)聲明的所有參數(shù)在放在下一行
AllowAllParametersOfDeclarationOnNextLine: false
# 不允許短的塊放在同一行
AllowShortBlocksOnASingleLine: true
# 允許短的case標簽放在同一行
AllowShortCaseLabelsOnASingleLine: true
# 允許短的函數(shù)放在同一行: None, InlineOnly(定義在類中), Empty(空函數(shù)), Inline(定義在類中,空函數(shù)), All
AllowShortFunctionsOnASingleLine: None
# 允許短的if語句保持在同一行
AllowShortIfStatementsOnASingleLine: true
# 允許短的循環(huán)保持在同一行
AllowShortLoopsOnASingleLine: true
# 總是在返回類型后換行: None, All, TopLevel(頂級函數(shù),不包括在類中的函數(shù)),
# AllDefinitions(所有的定義,不包括聲明), TopLevelDefinitions(所有的頂級函數(shù)的定義)
AlwaysBreakAfterReturnType: None
# 總是在多行string字面量前換行
AlwaysBreakBeforeMultilineStrings: false
# 總是在template聲明后換行
AlwaysBreakTemplateDeclarations: true
# false表示函數(shù)實參要么都在同一行,要么都各自一行
BinPackArguments: true
# false表示所有形參要么都在同一行,要么都各自一行
BinPackParameters: true
# 大括號換行,只有當BreakBeforeBraces設置為Custom時才有效
BraceWrapping:
# class定義后面
AfterClass: true
# 控制語句后面
AfterControlStatement: true
# enum定義后面
AfterEnum: true
# 函數(shù)定義后面
AfterFunction: true
# 命名空間定義后面
AfterNamespace: false
# struct定義后面
AfterStruct: true
# union定義后面
AfterUnion: true
# extern之后
AfterExternBlock: false
# catch之前
BeforeCatch: false
# else之前
BeforeElse: true
# 縮進大括號
IndentBraces: false
# 分離空函數(shù)
SplitEmptyFunction: false
# 分離空語句
SplitEmptyRecord: false
# 分離空命名空間
SplitEmptyNamespace: false
# 在二元運算符前換行: None(在操作符后換行), NonAssignment(在非賦值的操作符前換行), All(在操作符前換行)
BreakBeforeBinaryOperators: NonAssignment
# 在大括號前換行: Attach(始終將大括號附加到周圍的上下文), Linux(除函數(shù)、命名空間和類定義,與Attach類似),
# Mozilla(除枚舉、函數(shù)、記錄定義,與Attach類似), Stroustrup(除函數(shù)定義、catch、else,與Attach類似),
# Allman(總是在大括號前換行), GNU(總是在大括號前換行,并對于控制語句的大括號增加額外的縮進), WebKit(在函數(shù)前換行), Custom
# 注:這里認為語句塊也屬于函數(shù)
BreakBeforeBraces: Custom
# 在三元運算符前換行
BreakBeforeTernaryOperators: false
# 在構造函數(shù)的初始化列表的冒號后換行
BreakConstructorInitializers: AfterColon
#BreakInheritanceList: AfterColon
BreakStringLiterals: false
# 每行字符的限制,0表示沒有限制
ColumnLimit: 0
CompactNamespaces: true
# 構造函數(shù)的初始化列表要么都在同一行,要么都各自一行
ConstructorInitializerAllOnOneLineOrOnePerLine: false
# 構造函數(shù)的初始化列表的縮進寬度
ConstructorInitializerIndentWidth: 4
# 延續(xù)的行的縮進寬度
ContinuationIndentWidth: 4
# 去除C++11的列表初始化的大括號{后和}前的空格
Cpp11BracedListStyle: true
# 繼承最常用的指針和引用的對齊方式
DerivePointerAlignment: false
# 固定命名空間注釋
FixNamespaceComments: true
# 縮進case標簽
IndentCaseLabels: false
IndentPPDirectives: None
# 縮進寬度
IndentWidth: 4
# 函數(shù)返回類型換行時,縮進函數(shù)聲明或函數(shù)定義的函數(shù)名
IndentWrappedFunctionNames: false
# 保留在塊開始處的空行
KeepEmptyLinesAtTheStartOfBlocks: false
# 連續(xù)空行的最大數(shù)量
MaxEmptyLinesToKeep: 1
# 命名空間的縮進: None, Inner(縮進嵌套的命名空間中的內(nèi)容), All
NamespaceIndentation: None
# 指針和引用的對齊: Left, Right, Middle
PointerAlignment: Left
# 允許重新排版注釋
ReflowComments: true
# 允許排序#include
SortIncludes: false
# 允許排序 using 聲明
SortUsingDeclarations: false
# 在C風格類型轉(zhuǎn)換后添加空格
SpaceAfterCStyleCast: false
# 在Template 關鍵字后面添加空格
SpaceAfterTemplateKeyword: true
# 在賦值運算符之前添加空格
SpaceBeforeAssignmentOperators: true
# SpaceBeforeCpp11BracedList: true
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# 開圓括號之前添加一個空格: Never, ControlStatements, Always
SpaceBeforeParens: ControlStatements
# SpaceBeforeRangeBasedForLoopColon: true
# 在空的圓括號中添加空格
SpaceInEmptyParentheses: false
# 在尾隨的評論前添加的空格數(shù)(只適用于//)
SpacesBeforeTrailingComments: 1
# 在尖括號的<后和>前添加空格
SpacesInAngles: false
# 在C風格類型轉(zhuǎn)換的括號中添加空格
SpacesInCStyleCastParentheses: false
# 在容器(ObjC和JavaScript的數(shù)組和字典等)字面量中添加空格
SpacesInContainerLiterals: true
# 在圓括號的(后和)前添加空格
SpacesInParentheses: false
# 在方括號的[后和]前添加空格,lamda表達式和未指明大小的數(shù)組的聲明不受影響
SpacesInSquareBrackets: false
# 標準: Cpp03, Cpp11, Auto
Standard: Cpp11
# tab寬度
TabWidth: 4
# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always
UseTab: Never
到了這里,關于linux(wsl)下,vscode配置json文件,以及.clang-format文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!