本文介绍了Visual Studio Code格式为"{}"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu上.当我在Visual Studio Code中编写C ++代码时,它会自动掉毛,例如

I'm on Ubuntu. When I write C++ code in Visual Studio Code it automatically lints like

if (condition == true)
{
  DoStuff();
}

相反,我想这样做:

if (condition == true) {
  DoStuff();
}

我该怎么做?

我已经从市场上安装了 C/C ++ 扩展程序.

I've already installed the C/C++ extension from the marketplace.

推荐答案

基于@Chris Drew的答案

base on @Chris Drew's answer

  1. 转到首选项->设置
  2. 搜索C_Cpp.clang_format_fallbackStyle
  3. 点击编辑,复制到设置
  4. 从"Visual Studio"更改为"{ BasedOnStyle: Google, IndentWidth: 4 }"
  1. Go Preferences -> Settings
  2. Search for C_Cpp.clang_format_fallbackStyle
  3. Click Edit, Copy to Settings
  4. Change from "Visual Studio" to "{ BasedOnStyle: Google, IndentWidth: 4 }"

例如

  • "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
  • btw ColumnLimit: 0也很有帮助,因为Google限制会在您不需要时将您的代码破坏到下一行.
  • "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
  • btw ColumnLimit: 0 is helpful too, because google limit will break your code to next line when you do not need it.

如果您想要更多:

更多细节:

英语: https://medium.com/@zamhuang/vscode-how-to-custom-cs-coding-style-in-vscode-ad16d87e93bf

台湾: https://medium.com/@zamhuang/vscode-%E5%A6%82%E4%BD%95%E5%9C%A8-vscode-%E4%B8%8A%E8%87%AA%E5%AE%9A%E7%BE%A9-c -%E7%9A%84-coding-style-c8eb199c57ce

这篇关于Visual Studio Code格式为"{}"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:59