Home Download Buy Blog Forum Support

Append .sublime-snippet

Append .sublime-snippet

Postby Saxi on Fri Nov 08, 2013 5:39 pm

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.
Saxi
 
Posts: 102
Joined: Mon Nov 19, 2012 1:37 pm

Re: Append .sublime-snippet

Postby tito on Mon Nov 11, 2013 7:10 am

Done~ Save it as User/NewSnippetAutoName.py
Code: Select all
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 ');
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Append .sublime-snippet

Postby Saxi on Mon Nov 11, 2013 10:24 am

tito wrote:Done~ Save it as User/NewSnippetAutoName.py
Code: Select all
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 ');


Sweet, thanks!
Saxi
 
Posts: 102
Joined: Mon Nov 19, 2012 1:37 pm

Re: Append .sublime-snippet

Postby Saxi on Tue Nov 12, 2013 8:12 am

tito wrote:Done~ Save it as User/NewSnippetAutoName.py
Code: Select all
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 ');


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?
Saxi
 
Posts: 102
Joined: Mon Nov 19, 2012 1:37 pm

Re: Append .sublime-snippet

Postby tito on Fri Nov 15, 2013 1:34 am

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.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Append .sublime-snippet

Postby Saxi on Sat Nov 16, 2013 3:10 am

tito wrote: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.


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".
Saxi
 
Posts: 102
Joined: Mon Nov 19, 2012 1:37 pm

Re: Append .sublime-snippet

Postby tito on Sat Nov 16, 2013 11:58 pm

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.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 876
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Append .sublime-snippet

Postby dingdong on Thu Nov 28, 2013 7:42 am

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?
dingdong
 
Posts: 1
Joined: Thu Nov 28, 2013 7:41 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: sabhiram and 5 guests