VS Code设置C/C++代码格式化

快捷键Shift + Alt + F

打开文件->首选项->设置或者快捷键Ctrl + ,搜索设置clang如下图
VS Code Settings
在上图中 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
    format
  • 4 双击 Format Document 输入想要使用的快建键组合即可
发布了8 篇原创文章 · 获赞 8 · 访问量 251

猜你喜欢

转载自blog.csdn.net/whuer_xiaojie/article/details/105163144