How do I scope a VS Code custom snippet to files with ".sh" or ".bash" filename extensions?

191 Views Asked by At

I'm using VSCodium: ver 1.79.2, release: 23166

Example of my snippet which does not work, actually does not showing in editor:

"Insert: # EOF": {
  "scope": "sh,bash",
  "prefix": "eof",
  "body": [
      "# EOF $0",
  ],
  "description": "Insert EOF"
},

I expect that after typing the prefix, the [eof] menu to show up with option "insert EOF"

1

There are 1 best solutions below

0
On BEST ANSWER

You're supposed to use language IDs in the scope property. The language ID that VS Code uses as a catch-all for files with ".sh" or ".bash" is shellscript- not sh or bash.

There's a bit of a trick you can use to discover what language IDs exist (there might be a better way I don't know of): Open a settings.json file, and begin typing [ for a setting key, and then trigger autocomplete. Ex.

{
  "[" // put cursor after the [ and trigger autocomplete
}