SnipMate

SnipMate aims to provide support for textual snippets, similar to TextMate or other Vim plugins like UltiSnips. For example, in C, typing for<tab> could be expanded to

for (i = 0; i < count; i++) {
    /* code */
}

with successive presses of tab jumping around the snippet.

Originally authored by Michael Sanders, SnipMate was forked in 2011 after a stagnation in development. This fork is currently maintained by Rok Garbas, Marc Weber, and Adnan Zafar.

Installing SnipMate

We recommend one of the following methods for installing SnipMate and its dependencies. SnipMate depends on vim-addon-mw-utils and tlib.

NOTE: SnipMate does not ship with any snippets out of the box. We suggest looking at the vim-snippets repository.

Using SnipMate

Press and try :SnipMateOpenSnippetFiles for starting. Also see doc/SnipMate.txt to learn all SnipMate

FAQ

SnipMate doesn’t work / My snippets aren’t triggering

Try all of the following:

If all of the above check out, please open an issue stating your Vim version, a sample snippet, and a description of exactly what happens when you try to trigger a snippet.

How does SnipMate determine which snippets to load? How can I separate, for example, my Rails snippets from my Ruby snippets?

Primarily SnipMate looks at the 'filetype' and 'syntax' settings. Taking “scopes” from these options, it looks in each snippets/ directory in 'runtimepath' for files named scope.snippets, scope/*.snippets, or scope_*.snippets.

However we understand this may not allow for the flexibility desired by some languages. For this we provide two options: scope aliases and the :SnipMateLoadScope command. Scope aliases simply say “whenever this scope is loaded, also load this other scope:

let g:snipMate = get(g:, 'snipMate', {}) " Allow for vimrc re-sourcing
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby'] = 'ruby,rails'

will load the ruby-rails scope whenever the ruby scope is active. The :SnipMateLoadScope foo command will always load the foo scope in the current buffer. The vim-rails plugin automatically does :SnipMateLoadScope rails when editing a Rails project for example.

What are the snippet parser versions and what’s the difference between them?

Originally SnipMate used regex to parse a snippet. Determining where stops were, what the placeholders were, where mirrors were, etc. were all done with regex. Needless to say this was a little fragile. When the time came for a rewritten parser, some incompatibilities were a little necessary. Rather than break everyone’s snippets everywhere, we provided both the new (version 1) and the old (version 0) and let the user choose between them.

Version 0 is considered legacy and not a lot of effort is going to go into improving or even maintaining it. Version 1 is the future, and one can expect new features to only exist for version 1 users. A full list of differences can be found in the docs at :h SnipMate-parser-versions.

Release Notes

0.89 - 2016-05-29

0.88 - 2015-04-04

0.87 - 2014-01-04