在 C++ VSCode 中按 Enter 键时在新行上格式化花括号

问题描述

我在 settings.json 中启用了这些选项

"C_Cpp.vcFormat.indent.lambdaBracesWhenParameter": false,"C_Cpp.vcFormat.space.withinInitializerListBraces": false,"C_Cpp.vcFormat.newLine.scopeBracesOnSeparateLines": true,"C_Cpp.vcFormat.space.beforeInitializerListOpenBrace": true,"C_Cpp.vcFormat.space.beforeLambdaOpenParenthesis": true,"C_Cpp.vcFormat.space.beforeOpenSquareBracket": true,"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "newLine","C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": "sameLine","C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "newLine","C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "newLine","C_Cpp.formatting": "vcFormat","C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyFunction": true,"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyType": true,"C_Cpp.vcFormat.space.beforeEmptySquareBrackets": true,"C_Cpp.vcFormat.wrap.preserveBlocks": "allOneLinescopes","C_Cpp.vcFormat.space.pointerReferenceAlignment": "right","C_Cpp.intelliSenseEngineFallback": "Enabled","C_Cpp.clang_format_fallbackStyle": "Visual Studio","C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "newLine","C_Cpp.vcFormat.indent.caseContents": false,"C_Cpp.vcFormat.indent.namespaceContents": false,"C_Cpp.vcFormat.indent.caseLabels": true,"C_Cpp.vcFormat.space.removeBeforeSemicolon": false,"C_Cpp.vcFormat.space.insertAfterSemicolon": true,"C_Cpp.vcFormat.indent.caseContentsWhenBlock": true,"C_Cpp.vcFormat.space.afterKeywordsInControlFlowStatements": false,"C_Cpp.vcFormat.space.beforeBlockOpenBrace": false

如果我写

if(/*some instruction*/){}

如果光标在 {} 之间并按 Enter 键,我会得到这个

  if(/*some instruction*/)  
{
    
  }

我想要的是这个

  if(/*some instruction*/)
  {

  }

我没有找到在哪里设置。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)