2

I start typing the prefix "conso" and I would expect that the snippets suggestions will show at the top. In fact, it is working on MacOS. However, on Windows no snippet suggestions are shown.

.vscode/snippets/typescript.json

{
   "console": {
     "prefix": "console",
     "body": "console.log('$1', $1);$2"
   }
}

.vscode/settings.json

{ 
  "editor.tabCompletion": "on",
  "editor.snippetSuggestions": "top",
}

Extension Installed in Visual Code

    "rebornix.project-snippets"

I've tried restarting Visual Studio Code and even reloading the window, but the problem persists. It seems like the snippet itself is not being triggered properly.

Shankar CJ
  • 29
  • 2
  • BTW, welcome to Stack Overflow! Check out the [tour], and [ask] for tips like how to write a good title. – wjandrea Jul 27 '23 at 18:19
  • [Here's](https://github.com/MintPlayer/mintplayer-ng-bootstrap/tree/master/libs/mintplayer-ng-bootstrap-snippets) an example snippets project – Pieterjan Jul 28 '23 at 02:32
  • You are in a typescript file when you try to trigger this? The snippet looks fine, assuming that is the entire `typescript.json` file. – Mark Jul 28 '23 at 02:52
  • @Mark the user snippets is actually working, but that trying to get Project Snippet to work which uses the ( "rebornix.project-snippets") and that those are not yet working. – Shankar CJ Jul 28 '23 at 07:23

1 Answers1

2

I see you have your typescript.json snippets file in this location:

.vscode/snippets/typescript.json

It does not go there - the snippets folder is just for emmet snippets (and they have a very different form).

When you go to the Gear icon (lower left) and open User Snippets and choose your language, vscode will create the file in the proper location. Then you can open that - by going to the same Gear/User Snippets - look for your your .json file listed there and insert your snippet into that.

If you choose to create a snippets file for that particualr workspace, the snippets file would be located at

.vscode/<aNameYouChoose>.code-snippets

and your snippet would go into that file.


With the additional info that you were trying to get the Project Snippets extension to work, I had to go to its repository to see that it is deprecated:

Deprecated - This feature is now part of VSCode This feature now ships with visual studio code!

Steps to using built-in workspace snippets:

Create a {namehere}.code-snippets file in .vscode folder The file must be within .vscode folder (not in sub-folders) Your snippets can now be checked in and shared with your team Note: when using the snippet you will see (Workspace Snippet) in the intellisense autocomplete dropdown.

It is very unfortunate that he hasn't published the README info to the Marketplace version of the extension!

In any case, if you create a <aNameYouChoose>.code-snippets file in the .vscode folder that is where you put your snippets. It really doesn't matter what you name it as you cannot limit their scope by the fileName, but you can in each snippet itself with the `scope argument:

{

  "console": {
    "prefix": "console",
    "scope": "typescript",
    "body": "console.log('$1', $1);$2"
  }
}
Mark
  • 143,421
  • 24
  • 428
  • 436
  • The user snippets are working but try to get shared project snippets to work. that not working. the snippets are defined inside the git project and that we using the extension: `rebornix.project-snippets` – Shankar CJ Jul 28 '23 at 07:32