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

My Snippets

by erikgassler ST2/ST3

Sublime Text 2|3 plugin:Allows you quick access to your code templates through a context menu.

Details

Installs

  • Total 9K
  • Win 6K
  • OS X 2K
  • Linux 1K
Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 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
Windows 4 3 1 1 0 1 1 2 1 0 0 2 2 1 0 3 0 0 0 2 1 1 0 1 2 0 2 1 2 5 3 1 1 1 2 1 0 2 1 2 2 1 3 2 2 2
OS X 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 1 0

Readme

Source
raw.​githubusercontent.​com

My-Snippets

This plugin for Sublime Text 2|3 allows you to have quick access to your own commonly used code through a context menu instead of copy/pasting from files or some other coding library.

Installation

Available via Package Control - search for “My Snippets”.

Configuration

After installing you will need to edit the Preferences -> Package Settings -> My Snippets -> Settings - User file. Include the name and absolute path for each folder that contains your snippets library. Note that all sub-folders will also be automatically included. Note that folders will not appear in menu if they are empty. Note that relative paths are relative from Sublime folder inside the settings and packages are contained. See example below for example of Windows paths. Ex:

"folders":[
    {//Example of including library with a full path
        "display": "Example1",
        "path": "C:/Users/Me/AppData/Roaming/Sublime Text 3/Packages/User/JSSnippets/"
    },
    {//Example of including same library from a relative path
        "display": "Example2",//Snippets and subfolders will appear directly in the main snippets folder or root context menu.
        "path": "./Packages/User/JSSnippets/"
    }

After installing you will need to edit the Preferences -> Package Settings -> My Snippets -> Settings - User file. Include the name and path (relative to ?) for each folder that contains your snippets library. Note that all sub-folders will also be automatically included.

If you want all your snippets directly under “My Snippets” in the context menu, leave the display value as an empty string. Ex: "display": "",

Most Recent Update:

0.17.8: Fixed issue with .sublime-snippet files not correctly removing wrapping XML in Sublime Text 3.

Older updates

Usage:

Folders and files will appear in a context menu (Right click in windows) titled “My Snippets”. Selecting a menu item will result in all text from the associated file being injected into your open document at the cursor(s) and replacing any selected text.

The menu items are displayed with their exact file name, minus the extension. I recommend using descriptive file naming conventions. Note that for the 2nd snippet type - see below - file extensions are not needed, but I personally use them in my snippets for syntax highlighting when writing my snippets.

Snippets to be used in the context menu can have any extension.

For normal sublime snippets - with extension .sublime-snippet - follow normal rules for setting up the file, as detailed in the docs reference: See http://docs.sublimetext.info/en/latest/reference/snippets.html for documentation on creating these snippets.

My Snippets also allows snippets with any other file extension. When using file extensions other than .sublime-snippet include only your exact snippet content in the file. Do not wrap your snippet with any XML. You can however use all environment variables - IE. $SELECTION, $1, etc - that you would use in a normal snippet.

My Snippets automatically excludes files from “binary_file_patterns” and “file_exclude_patterns” found in your Preferences.sublime-settings settings.

Key Binding:

By default shift+enter is a key binding setup for initiating snippets based on tags.

To set a tag for a snippet include the tag value inside square brackets in the file name for the snippet - such as “My Snippet [mysnip].html”.

Then in your code you can type in your tag followed by the key bind command (shift+enter) to replace the tag with the linked snippet.

If multiple snippets are loaded with the same tag only the last one loaded can use the key bind feature.

Please note that the text that is looked up as the tag will be deleted, regardless of whether or not a valid key was found from the tag.

Also note that if multiple cursor locations exist, all cursors will be scanned for tags and only the last valid snippet will be used; And any tags found preceding any of the cursors will be deleted, even if they were not the tag used for the loaded snippet.

Version Update History:

0.17.8: Fixed issue with .sublime-snippet files not correctly removing wrapping XML in Sublime Text 3.

0.16.0: Added ability for users to have relative paths for their library paths.

0.15.0: Added ability to setup tab-like key bindings to initiate snippets.

0.14.3: Fixed missing loading of debug setting.

0.14.2: Whoops, forgot to include the updated settings file.

0.14.1: Fix bug from invalid character.

0.14.0: Add option for displaying “My Snippets” menu in top menu.

0.13.0: Add option for display file extensions in menu

0.12.0: Added option for main context menu folder's display

0.11.5: Reworked threading to fix ST2 issues

0.11.4: Fixed threading bug found in Sublime Text 2