How do I edit snippets in Sublime Text 3?
SublimetextSublimetext3Sublimetext Problem Overview
In Sublime Text 3, how do I edit my pre-existing snippet files? Is there a way of doing this within ST?
At the time of writing, there doesn't seem to be a straightforward answer to this anywhere on the web.
Sublimetext Solutions
Solution 1 - Sublimetext
Custom snippets are saved in a .sublime-snippet
file that you create when you first save the snippet.
By default, these are placed in the "User" package. You can either browse to the file like you would any other file, or using PackageResourceViewer: Open Resource
-> User
-> [name of your snippet file]
Solution 2 - Sublimetext
For those of you that like a visual instruction here it is:
Then, you can find your snippet like this:
Solution 3 - Sublimetext
Here are the steps I had to follow (figure out on my own) for anyone else who wants to edit the built-in snippets of Sublime (in my case Javascript's "fun" "function" snippet). Note: this assumes you've installed the Package "PackageResourceViewer" already:
- --> PackageResourceViewer: Extract Package
- Then specify which package(s) you want to extract. FWIW this process was a bit confusing for me ... somehow I managed to select everything? but I only wanted/needed "JavaScript".
- Wait a second or three for Sublime to extract these (no idea what this does in background, I assume maybe unzipping/extracting loose files to your file system?)
- You'll get a confirmation dialog about your successful extraction
- NOW you can edit built-in snippets by --> PackageResourceViewer: Open Resource
- --> Select "JavaScript" (in my case)
- --> Select "/Snippets" (in my case)
- --> Select your snippet (in my case it was "function-(fun).sublime-snippet" or something like that.
- The file will open and you can modify/save your changes ... FINALLY!
WAY too complicated IMHO but at least it works.
Solution 4 - Sublimetext
If someone (like me) is looking to edit a custom snippet:
open file *.sublime-snippet
which exists in
[home_directory]/.config/sublime-text-3/Packages/User/
If you have another file organization:
- Start to make new snippet - Tools->developer->new snippet
- Try to save it. Sublime shows you the right directory with snippets
Solution 5 - Sublimetext
Here is how to edit built-in snippets manually on macOS, in this case the JavaScript snippets. This is a way to do it without installing plugins:
- Right click the Sublime Text app, select "Show Package Contents"
- In the Finder, navigate to Contents -> MacOS -> Packages
- Copy the
JavaScript.sublime-package
file to~/Library/Application Support/Sublime Text 3/Installed Packages
- Change the file name from
JavaScript.sublime-package
toJavaScript.zip
and unzip the file - In your text editor, edit the contents of the unzipped
JavaScript
folder as required (e.g. delete thefun
snippet from the Snippets folder) - Zip up the
JavaScript
folder again, rename it fromJavaScript.zip
toJavaScript.sublime-package
and leave it in theInstalled Packages
folder. - Restart Sublime. Your new JavaScript package will override the built-in package.
Solution 6 - Sublimetext
Tools -> Developer -> View package file -> search for the existing snippet. Change and save.