简体   繁体   中英

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:

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).

I can't find any setting in the VS Code settings JSON file for this extension.

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

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:

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

in this directory, there are two files: c.json, cpp.json

In each there are json entries for each snippit. I edited a couple in the c.json to test and they now format as I want. Thanks Ali! your suggestions got me thinking!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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