3

I am a long time Atom user. I finally decided to switch over to VS Code but there is one thing that if I cannot solve I am going back to Atom. I am a hardware engineer so I primarily write C code. I am looking for a way to fix the IntelliSense snippet code formatting.

For example, when I start typing while and press Tab to autocomplete, I get this:

while (/* condition */)
{
   /* code */
}

I am looking for a way for the autocomplete to put the curly brace on the same line as such:

while (/* condition */) {
   /* code */
}

From what I can tell, the only way to change this is to edit the default snippets that come with the C/C++ extension. I have tried going to ~/.vscode/extensions/ms-vscode.cpptools-1.2.2 (I am on a Mac) but to no avail. There is no snippets folder.

I have also tried adding

"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "sameLine",
"C_Cpp.clang_format_style": "WebKit",
"C_Cpp.clang_format_fallbackStyle": "WebKit"

to the settings.json file but, again, nothing.

This is incredibly important to fix for me so if you have any solutions I am all ears. Thank you.

Sarp User
  • 31
  • 2
  • these snippets are not that complex, write your own versions in the custom c snippets file, start all these snippets with a unique prefix like: `cwhile`, `cfor`, `cswitch` – rioV8 Apr 10 '21 at 12:41

1 Answers1

0

You may need to create a custom snippet. See: Create your own snippets.

To “replace” the existing snippet, you’ll need to hide it from IntelliSense. See: Can I remove snippets from IntelliSense?

RIP Atom

Mikol Graves
  • 320
  • 4
  • 6