简体   繁体   English

VS Code Snipets for C/C++ 中花括号的格式

[英]Format for curly braces in VS Code Snipets for C/C++

I installed the C/C++ Snippets extension in VS Code, and it creates a snippet like this:我在 VS Code 中安装了 C/C++ Snippets 扩展,它创建了一个像这样的片段:

for ( ) 
{
    // your code
}

but I want the open brace on the keyword line:但我想要关键字行上的左大括号:

for ( ) {

I found this topic for C/C++ formation in VS Code: "Format Curly Braces on Same Line in C++ VS Code" but it didn't solve the problem (so, the snippet extension doesn't follow the C formatting "rules" in VS Code, I guess).我在 VS 代码中找到了 C/C++ 形成的这个主题:“在 C++ VS 代码的同一行上格式化花括号”,但它没有解决问题(因此,片段扩展不遵循 C 格式“规则” VS Code,我猜)。

I can't find any setting in the VS Code settings JSON file for this extension.我在 VS Code 设置 JSON 文件中找不到此扩展的任何设置。

Anyone have an idea?有人有想法吗?

(In the ideal world, the curly brace for functions would remain on the next line and only braces associated with keywords would be on the same line.) (在理想情况下,函数的大括号将保留在下一行,只有与关键字关联的大括号才会在同一行。)

Thank you,谢谢,

-Vin -Vin

I did some intense digging and found the name of the file that holds the snippits, then looked in all the "usual suspect" places and found it:我做了一些深入的挖掘,找到了包含 snippits 的文件的名称,然后查看了所有“常见的可疑”位置并找到了它:

C:\Users\.vscode\extensions\hars.cppsnippets-0.0.14\snippets\ C:\Users\.vscode\extensions\hars.cppsnippets-0.0.14\snippets\

in this directory, there are two files: c.json, cpp.json在这个目录下,有两个文件: c.json,cpp.json

In each there are json entries for each snippit.每个片段都有 json 条目。 I edited a couple in the c.json to test and they now format as I want.我在 c.json 中编辑了一对进行测试,它们现在可以按照我的意愿进行格式化。 Thanks Ali!谢谢阿里! your suggestions got me thinking!你的建议让我思考!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM