I've been using ultisnips for several
weeks now.
I think the main advantages of this plugin are the following:
- It is pretty fast even with a great number of snippets available.
- The basic syntax to define a new snippet is easy to understand, thus it is
easy to quickly create a new snippet doing what you want to do. (For more
complex snippets some additional work can be required.)
- It works very well out of the box; a basic configuration allow you to use
snippets very quickly.
- It is really configurable. Even if the basic configuration works well, if
you're a power user you can really tune it pretty finely.
First of all ultisnips is a snippet engine which means that the plugin provides
features to use snippets but doesn't provide the snippets themselves. To get the
snippets, the author recommends
vim-snippets.
Once you got both plugins installed you'll be able to use your snippets.
The snippets' definitions are stored in files named following patterns:
ft.snippets
, ft_*.snippets
, or ft/*
, where ft
is the 'filetype' of the
current document and *
is a shell-like wildcard matching any string including
the empty string. (Note that dotted filetype syntax like cuda.cpp
is
supported.)
This way snippets specific to a filetype are expanded only when the buffer's
filetype is set. A special filetype all
is available to create snippets
expanded on all buffers.
In addition to the snippets provided by vim-snippets, the user can define its
own snippets. My recommendation would be to place them in the directory
~/.vim/my-snippets/Ultisnips
this way Ultisnips will find them without
additional configuration and it is easy to maintain them in a dotfile
repository.
To expand the snippets, Ultisnips provides a variable g:UltiSnipsExpandTrigger
which defines the mapping which will trigger the expansion (I chose
** which is pretty convenient for me). Note that an integration
should be possible but I didn't test it by myself).
For power users, Ultisnips also provides some functions to customize the behavior
of the expansion, or to trigger it differently. See :h
UltiSnips-trigger-functions
This is the first snippet manager that I really used extensively and I think this
is a good one to begin with for its simplicity out of the box and its
possibility to be tuned.
Finally here is a list of screencasts which give a good introduction to the
plugin: