Sublime Forum

Append .sublime-snippet

#1

I don’t know why it doesn’t already do this, but it would be nice when saving a new snippet it would automatically have .sublime-snippet for the extension.
I can’t count how many times I saved a snippet only unable to find it because I forgot to add it.

0 Likes

#2

Done~ Save it as User/NewSnippetAutoName.py

[code]
import sublime_plugin, sublime

class NewSnippetAutoName(sublime_plugin.EventListener):

def on_activated(self, view):
	if view and view.substr(sublime.Region(0, 9)) == '<snippet>':
		view.set_name('ZZZ.sublime-snippet ');[/code]
0 Likes

#3

[quote=“tito”]Done~ Save it as User/NewSnippetAutoName.py

[code]
import sublime_plugin, sublime

class NewSnippetAutoName(sublime_plugin.EventListener):

def on_activated(self, view):
	if view and view.substr(sublime.Region(0, 9)) == '<snippet>':
		view.set_name('ZZZ.sublime-snippet ');[/code][/quote]

Sweet, thanks!

0 Likes

#4

[quote=“tito”]Done~ Save it as User/NewSnippetAutoName.py

[code]
import sublime_plugin, sublime

class NewSnippetAutoName(sublime_plugin.EventListener):

def on_activated(self, view):
	if view and view.substr(sublime.Region(0, 9)) == '<snippet>':
		view.set_name('ZZZ.sublime-snippet ');[/code][/quote]

Is there a way to modify this so zzz (which I renamed to mySnippet) is highlighted (not .sublime-snippet) so you can just start typing snippet and name and hit enter to save?

Also, what causes this to run, will Sublime Text run any python files in User automatically or is that a special file name that causes this to happen?

0 Likes

#5

Is very easy to write your own “New snippet” command, which can set the default name, the default folder… and select automatically the name of the file.

0 Likes

#6

I don’t know Python and haven’t got into making plugins for Sublime.
Is there a way to control the cursor w/ sublime and the file dialog so text can be “preselected”.

0 Likes

#7

There is a package named “SnippetMaker”, install it, you will see some cool things, anything that does not match your desires, just open a bug report to the Package Maintainer.

0 Likes

#8

Is there a way to modify this so zzz (which I renamed to mySnippet) is highlighted (not .sublime-snippet) so you can just start typing snippet and name and hit enter to save?

0 Likes