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

My Snippets

by erikgassler ALL

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

Details

  • 0.18.0
  • github.​com
  • github.​com
  • 11 years ago
  • 56 minutes ago
  • 11 years ago

Installs

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