Sublime Forum

ST3: disable snippets shipped by default

#1

In Sublime Text 2 I was able to delete all the *.​sublime​-​snippet files for a package (in my case PHP) because they were just annoying to me.

This is not possible anymore in ST3 because the package resides within the PHP.sublime-package within the Sublime Text.app. Is there another way to disable snippets for a language?

0 Likes

#2

I read up on the ST3 documentation, and it says

[quote]http://www.sublimetext.com/docs/3/packages.html
Overriding Files From a Zipped Package

To override a file in an existing package, just create a file with the same name under the Packages/ directory.

For example to override the file function.sublime-snippet in the Python.sublime-package package that ships with Sublime Text, create a directory called Python under the <data_path>/Packages directory, and place your function.sublime-snippet file there.[/quote]

If I create an empty file ~/Library/Application Support/Sublime Text 3/Packages/PHP/define(-).sublime-snippet ST3 crashes upon start. If I copy the snippet from the ZIP file and change the tab trigger to something else, now both the trigger I don’t like in the first place and the new trigger work.

0 Likes

#3

Odd I just tried it (on my Windows machine) and it overrides the snippet fine. Mind posting your define(-).sublime-snippet file so I could test with yours?

0 Likes

#4

You are right, I now got it to work, it seems that I had another copy of the package in the folder. The quick solution for me now was to change the scope for each snippet to something that doesn’t apply to PHP. Thanks!

0 Likes

#5

How can I get this to work on Mac? I cannot stand the default forced CSS snippets. Everytime I type tab twice it inserts “Windows”

0 Likes

#6

You need to override the snippets. As hubert stated, you can change the scopes of the snippets so they are not triggered.

0 Likes

#7

Doesn’t work when trying to override value-of on an xsl document. enter val and hit tab. There is nowhere this snippet is being added, therefore no way to alter/remove.

0 Likes

#8

I just tried it in ST3. I didn’t get any snippet. I’d guess you have a plugin that is inserting the snippet, though I could be wrong.

0 Likes

#9

I have this problem too.

Wrote a simple script to disable all default snippets for Python language: gist.github.com/dreadatour/7475747 (OS X only).
This should work for another languages too. Hope this helps.

For Sublime Text author (if his reading this =): please, make the config option to disable default snippets. At least Python snippets are awful and annoying!

0 Likes

#10

[quote=“Dreadatour”]I have this problem too.

For Sublime Text author (if his reading this =): please, make the config option to disable default snippets. At least Python snippets are awful and annoying![/quote]

Just out of curiosity, what problems do you have with the Python snippets? I’ve found them to be helpful, but I don’t really use any beyond the class and function creation ones.

0 Likes

#11

Much easier way I found (in newer builds overriding didn’t help).

First install Package Resource Viewer.

Extract “PHP” package (ctrl+shift+p -> extract -> select PHP). If PHP is not there, most probably you already have it extracted in your Packages folder, so delete it.

Enter the extracted PHP directory and run rm *.sublime-snippet or remove all snippets, BUT NOT the other files.
Rename this directory to something like PHPCustom (this step leaves syntax and other PHP stuff, but not the snippets).
Add PHP to ignored packages in the settings

[code] “ignored_packages”:

	"Vintage",
	"PHP"
],[/code]

That’s it!

2 Likes

#12

Sorry for bumping, but I wanted to point something out I found out:

I just tried to replace function.sublime-snippet for Python. First it did not work, but then I found out that the Sublime 3 docs are not up to date:

http://www.sublimetext.com/docs/3/packages.html

It says the replacing file has to be put into Packages/[name of package].

Since for Python the snippets seem to be in “Python/Snippets” the replacing file also has to be in the subfolder Snippets/ ! … maybe one could update the docs at this point?

0 Likes

#13

FYI @wbond

0 Likes

#14

In build 3143 I found that the final step here of ignoring PHP removed syntax highlighting. Unfortunately, it is that last step that disables the snippets, and I like to have syntax highlighting.

Instead of the last ignored_packages step I edited the files in the Snippets subdirectory, adding “zz” in front of all the tabTrigger texts using sed so that the trigger is something I’ll never type, like so:

for foo in *snippet; do sed 's/tabTrigger>/tabTrigger>zz/' -i $foo; done

0 Likes

#15

you may want to vote this feature request up:

0 Likes

#16

Most default snippets don’t tend to follow the specific users’ coding standard so it ends up costing the dev more time in reformatting them when using them than simply typing it from scratch or creating their own snippets…

Or, when a language is used which uses the same extension - for example I use GLua to code which is Lua with C Style operators and continue; so I don’t use or, and, etc… ( It also makes it much easier to port the logic to other languages because there isn’t a ton of English commands being used - I do use language files, but still find and replace in files can still be sloppy otherwise )… So I rewrote the snippets for Lua to match GLua code and my coding standards along with adding new…

Honestly though - I’ve found snippets to be more cumbersome to use to be worthwhile… I need to either find a new keybind to quickly access them or write an AutoHotkey script to open a snippet wheel or something to quickly choose between them and then call the relevant hotkey in Sublime Text…

Or if there was a way to add them to the sidebar and get rid of project files display - it may be more productive to use them then…

1 Like