James
James

Reputation: 1548

Where are the settings for the VSCode snippet feature stored?

Normally, whenever you make a settings-related change in VSCode, it adds a line to your "settings.json" file, which is located by default at:

C:\Users\james\AppData\Roaming\Code\User\settings.json

However, when I perform the following steps:

Ctrl + Shift + P --> Insert Snippet --> Search for "log" --> Click on the eye

This disables the snippet for "console.log". However, it does not make any changes to my "settings.json" file.

After poking around in the Code profile directory, it seems like there are two snippet related directories:

C:\Users\james\AppData\Roaming\Code\User\snippets
C:\Users\james\AppData\Roaming\Code\User\sync\snippets

However, there aren't any changes to these directories either, which leaves me stumped as to where the eye-related-changed could be stored.

  1. Where is this information for snippets stored?
  2. And how would I disable the console.log snippet on a per-workspace level like I would with a ruler or any other VSCode setting?

For reference, the relevant source code seems to be located here: https://github.com/microsoft/vscode/blob/8feb40b9284c339e2d1b0a493641e603b7f84d3d/src/vs/workbench/contrib/snippets/browser/snippetsService.ts#L165

But having the source code isn't very helpful here, as I am not really familiar with the VSCode codebase.

Upvotes: 1

Views: 235

Answers (1)

Mark
Mark

Reputation: 180659

I can only answer question 1 and I don't know how helpful the answer will be.

When I set the log warn snippet to ignore I found this line

snippets.ignoredSnippets["snippets/javascript.code-snippets/Log warning to console"]

in this file

C:\Users\Mark\AppData\Roaming\Code\User\globalStorage\state.vscdb

For viewing that type of file and other good information about workspace state see https://stackoverflow.com/a/58905720/836330.

Maybe you can copy that snippets.ignoredSnippets entry into the workspace level storage located at

C:\Users\Mark\AppData\Roaming\Code\User\workspaceStorage

and then the latest folder/state.vscdb ? My guess is that you can only ignore snippets on a global (user) basis and not per workspace.

Upvotes: 1

Related Questions