ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Better​Snippet​Manager

by math2001 ST2/ST3

A Sublime Text plugin to manage your snippets

Details

Installs

  • Total 408
  • Win 209
  • OS X 145
  • Linux 54
Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9
Windows 0 1 0 0 1 2 1 0 0 1 1 1 1 1 0 0 1 1 1 0 1 3 2 1 1 1 3 0 0 5 1 0 2 1 1 3 0 3 1 0 0 1 0 2 0 2
OS X 0 1 1 0 0 1 0 1 1 1 0 0 1 1 1 0 0 0 2 2 0 1 0 0 0 0 2 0 2 0 1 1 0 0 3 0 3 0 0 5 1 0 0 0 1 0
Linux 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 3 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Better Snippet Manager

You can list all your snippets (even in infinite sub-folders, they're listed in one panel, for quick access) You can create some snippet interactively.

The two commands are available in the command palette.

Usage

Create new snippets

You can create a new snippet by selecting up in the command palette BetterSnippetManager: Create New Snippet.

It's going to ask you different snippet specific questions: the trigger, the description, the scope.

If you're not aware of any of them, I strongly recommend having a look at the community powered unofficial documentation

In addition, it's also going to ask you the folder to save this snippet in, and the file name of you snippet.

The folder name is defined with the scope you're currently in. So, if you're writing JSON, it's going to propose you to save this in a json folder (because the scope is source.json). You can of course change this (note that if you put nothing in, it's going to put it at the root of your folder (in this case User)).

The filename has to have the extension .sublime-snippet to be taken into account by Sublime Text. So, it's added by default. The name alone is defined by the trigger you chose earlier in the process, but you can change this as well.

Once this is done, it'll create the snippet file, and open it in Sublime Text for you.

demo creating Sublime Text snippets using BetterSnippetManager

The content of the snippet is the content of your selection when you created ran BetterSnippetManager: Create New Snippet (it can be empty, it's just a little trick)

Edit existing snippets

You can edit existing snippets by searching up in the command palette: BetterSnippetManager: Edit Snippets. It'll list all your snippets (event the ones that are in sub-folders). It'll open the hovered one in the background. Now, you just need to hit enter to open it up.

demo listing Sublime Text snippets using BetterSnippetManager

All your snippets in one folder

If you're used to putting all your snippets inside a folder, you can configure BetterSnippetManager take this into consideration when listing and creating your snippets.

You need to edit BetterSnippetManager's settings (not your global ones). To do so, you can search up in the command palette Preferences: BetterSnippetManager Settings, or use the menus Preferences → Packages Settings → BetterSnippetManager.

In the right file, you can add this:

"snippets_folder": "my_snippet_folder"

and, like this, BetterSnippetManager will go straight into this folder (so don't list the snippet outside of it, which shouldn't be a problem).

SaneSnippet is supported!

The commands stay exactly the same, all you have to do is set this plugin setting use_sane_snippet to true!

Note: of course, you have to install SaneSnippet

Here's what a Sane Snippet looks like:

---
description: nice print for debug
tabTrigger:  print
scope:       source.python
---
print("$TM_FILENAME:$TM_LINE_NUMBER", $1)

Awesome, right?

Installation

Using package control

  1. Open up the command palette: ctrl+shift+p
  2. Search for Package Control: Install Package
  3. Search for BetterSnippetManager
  4. Hit enter :wink:

Using the command line

cd "%APPDATA%\Sublime Text 3\Packages"             # on window
cd ~/Library/Application\ Support/Sublime\ Text\ 3 # on mac
cd ~/.config/sublime-text-3                        # on linux

git clone "https://github.com/math2001/BetterSnippetManager"

Which solution do I choose?

It depends on of your needs:

  • If you intend to just use BetterSnippetManager, then pick the first solution (Package Control), you'll get automatic update.
  • On the opposite side, if you want to tweak it, or even contribute (:+1:), use the second solution. Note that, to get updates, you'll have to git pull

How to open the README

To open their README, some of the packages add a command in the menus, others in the command palette, or other nowhere. None of those options are really good, especially the last one on ST3 because the packages are compressed. But, fortunately, there is a plugin that exists and will solve this problem for us (and he has a really cute name, don't you think?): ReadmePlease. :tada:

Note

In every screenshot, I was using the Boxy Theme (Monokai), with the corresponding color scheme. The font was Droid Sans Mono.