Sublime Forum

[SOLVED] Change default snippet

#1

Hello,
I have default snippets Javascript with var and I would like to change in let

for (var i = Things.length - 1; i >= 0; i–) {
Things[i]
}

The file Programme / Sublime Text 3 / packages / Javascript.sublime-package contains the snippet but I can’t edit it.

Do you know another means please ?

Thanks

0 Likes

#2

You will need to create what is known as an override for that snippet file. Override refers to your version of the default shipped files that will be used by Sublime Text in place of it’s default file.

To create an Override, you will need to know what file you have to override. In Sublime Text, you can do this by using View Package File from the command palette.

In your case, you want to override a JavaScript snippet file. All the snippets for JavaScript are in JavaScript/Snippets. Find the file name of that snippet. For brevity’s sake, let the file name be example_snippet.sublime-snippet.

So now create JavaScript/Snippets/example_snippet.sublime-snippet in the Packages directory, place the snippet content there, edit the portion you want & save it. You should now get this snippet content every time you use it instead of the default one.

0 Likes

#3

Ok, Thanks for the answer UltraInstinct

I have found the snippet filename : for-()-{}-sublime-snippet.sublime-snippet

But I don’t find the JavaScript / Snippets / in Programmes/Sublime text 3/Packages. In this directory I have only files with sublime-package extention.

Then I have placed the new snippet file in %appdata% /sublime text 3/packages /user and now I have two snippets one with var and other with let.

I have no an override

0 Likes

#4

You can get to the Packages directory by going to Preferences -> Browse Packages ... from the main menu. There you will have to create a folder called JavaScript and then a sub folder called Snippets and then place the snippet (with the same file name as the default snippet file name) file there.

If you place the snippet file in User, then that becomes your own snippet file & not an override.

All the installed packages will be in ~/Sublime Text 3/Installed Packages and not in ~/Sublime Text 3/Packages.

0 Likes

#5

OK, override now.
That’s great

Thanks for the help @UltraInstinct05
Have a nice day

0 Likes

#6

You can use your own snippet as well that uses let instead of var, no problemo. Just that now there will be two snippet triggers in the Auto Complete instead of one. (One is your own & the other is the Default snippet).

0 Likes