Visual Studio Code可以通過以下快捷鍵 格式化代碼:
On Windows Shift + Alt + F
On Mac Shift + Option + F
On Ubuntu Ctrl + Shift + I
VSCode更改格式化C++代碼方式
File --> Preference --> setting --> 搜索 clang_format -->
在C_Cpp:Clang_format_fallback Style的輸入窗中填入如下代碼風格之一:
Visual Studio LLVM,Google,Chromuim, Mozilla, WebKit
或者:
{ BasedOnStyle: LLVM, IndentWidth: 4 }
//IndentWidth是縮進值,可自定義,默認爲2
My Clang_format_style
{ BasedOnStyle: Google, IndentWidth : 4, ColumnLimit : 200, BinPackArguments : false, BinPackParameters : false, BreakBeforeBraces : Custom, BraceWrapping : { AfterFunction: true } }