快捷键Shift + Alt + F
打开文件->首选项->设置
或者快捷键Ctrl + ,
搜索设置clang
如下图
在上图中 C_Cpp:Clang_format_style
下面的输入框中输入:
{
BasedOnStyle: Google,
UseTab: Never,
IndentWidth: 4,
TabWidth: 4,
AllowShortIfStatementsOnASingleLine: false,
ColumnLimit: 0
}
设置为Google排版方式
Ubuntu 下修改格式化快捷键
Ubuntu 下代码格式化快捷键默认为:Shift+Ctrl+I
为了保持和Windows一致,修改格式化快捷键
- 1 打开vscode命令行,快捷键:
Shift+Ctrl+P
- 2 在命令行输入
Keyboard shortcuts
搜索出现:Preferences:Open Keyboard Shortcus
- 3 打开
Preferences:Open Keyboard Shortcus
,搜索format
- 4 双击 Format Document 输入想要使用的快建键组合即可