Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the default snippets for C++ stored in VS Code?

So I've been using VS Code for a while now and I noticed that for some reason it started having extra snippets which I did not make come up in options, while they are useful I would like to edit them to my personal code formatting style.

I've tried looking for the json file which holds them however I am unable to locate it anywhere. I figured it would be in my install directory however the cpp.json file there simply defines the #pragma region snippet only.

For reference I looked in this location: C:\Users\Rietty\AppData\Local\Programs\VSCode\resources\app\extensions\cpp\snippets

A difference to show the two snippets is like so: snippet example and my user defined one which is marked with a user snippet next to the description.

I also got many new for loops and so on and so forth:

loops

Where can I find the location of these new snippets so I can edit them to my standards/formatting style?

Update:

I spent a decent bit looking this up and it seems the reason for this is due to the VSCode CPP Tools extension. Recent changes indicate that this occurred due to moving snippets to the hard-coded lexer from the relevant json file and that it is currently intended.

However an issue was already filed and is hopefully slated to be fixed sometime February 2019.

like image 289
Rietty Avatar asked Oct 17 '22 07:10

Rietty


1 Answers

This was fixed in release 0.22.0 of Visual Studio Code - CPP Tools with the release of the suggestSnippets setting. Now you don't have to worry about duplicating snippets due to the language server and can only use your hand made ones.

To change this setting:

  • Click Ctrl+Shift+P and type in "view: show extensions".
  • Open the C/C++ extension by Microsoft
  • Click the gear, then "Extension Settings"
  • Type "Suggest Snippets"
  • Deselect the box "If true, snippets are provided by the language server".
like image 144
Rietty Avatar answered Oct 21 '22 08:10

Rietty