sponsor Vim development Vim logo Vim Book Ad

UltiSnips : The ultimate snippet solution for python enabled Vim.

 script karma  Rating 501/145, Downloaded by 2911    Comments, bugs, improvements  Vim wiki

created by
Holger Rapp
 
script type
utility
 
description
UltiSnips is the Ultimate solution for snippets under Vim. Snippets are intelligent texts that spare you a lot of typing. Like many snippets solutions, this one ins heavily inspired by TextMates Snippet Syntax and offers all features that TextMate offers plus some more. But in Vim.

Screencasts:
Intro: http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/
Basic Snippets: http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/
Version 2.0s new features: http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/
Python Interpolation: http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/

UltiSnips has the following features (incomplete list):

- TextMates snippet syntax
- Tabstops, Placeholders (also nested)
- Mirrors and Transformations (also inside Placeholders)
- ShellCode, VimCode and a very powerful PythonCode interpolation
- Live update as you type
- snippets for file types and snippets that are always defined
- same name, multiple snippets
- recursive snippets: snippet in snippet
- forward and backward jumping to placeholders and tab stops
- convert script to download and convert TM bundles, convert script to reuse snipmates snippets.
- automatically reload snippet definition files when they changed.
- extend existing snippet definitions. For example cpp extends c, so that all c snippets are also available in cpp.
- options for snippets: expand only at the beginning of line, inword, convert tabs-to-spaces....
- multi word or regular expression triggers are supported and awesome!
- edit snippets with normal mode commands and move around in them freely while editing
- support for anonymous triggers that other scripts can define on the fly e.g. for automatic completion of parameters of your own functions.
- > 400 unit tests to guarantee that stuff works.
- Tested on Linux, Mac OS X and Windows.

There have been many attempts to do things right; I think, this one nails it.

UltiSnips is a community project, more than 15 people have contributed to it so far. Join in by providing feedback, snippets or code!

Try it:
Example 1:
- open /tmp/file.c
type for<tab>endcounter<c-j>mycounter<c-j><c-j>int a = 3;
yields:
------------------- SNIP -------------------
for(size_t mycounter = 0; mycounter < endcounter; ++mycounter)
{
int a = 3;
}
------------------- SNAP -------------------

Example 2:
- open /tmp/blah.help
- :set ft=help
- type sec<tab>MY COOL SECTION<c-h>blah
yields:
------------------- SNIP -------------------
=============================================================================
MY COOL SECTION                                        *blah-my-cool-section*

blah
------------------- SNAP -------------------


If you like the script, please contact me and vote for the script!
 
install details
To use UltiSnips, you need a python enabled Vim 7. You have python if either
   :echo has("python") or :echo has("python3")
yields '1'. Recent versions have been tested with python 2.7 and python 3.2,
theoretically, UltiSnips should work with all versions >= python 2.6.

Using Pathogen:                                     *UltiSnips-using-pathogen*

If you are a Pathogen user, you can track the official mirror of UltiSnips on github: >

   $ cd ~/.vim/
   $ git submodule add https://github.com/SirVer/ultisnips bundle/ultisnips

See the pathogen documentation how to update a bundle.

Using Bzr:                                               *UltiSnips-using-bzr*

To track the main repository on github, you will need bzr
(http://bazaar-vcs.org/). It is in all major linux distribution (either
package bzr or bazaar) and can be easily installed under Mac OS X: >
   $ pip install bzr

To get UltiSnips, check it out into a directory of your choice. Then add this
directory to your Vim runtime path: >
   $ cd ~/.vim/
   $ bzr get lp:ultisnips ultisnips_rep
   $ vim ~/.vimrc

add the line: >
   set runtimepath+=~/.vim/ultisnips_rep

Restart vim. UltiSnips should work now. To access the help, use >
   :helptags ~/.vim/ultisnips_rep/doc
   :help UltiSnips

To Update an installation, simply pull the latest revision: >
   $ cd ~/.vim/ultisnips_rep
   $ bzr pull

Using a downloaded packet:               *UltiSnips-using-a-downloaded-packet*

See *UltiSnips-using-bzr* Just unpack into a directory of your choice and add
the path to runtimepath.


Project page: https://launchpad.net/ultisnips
Bug Tracker: https://bugs.launchpad.net/ultisnips
Help File online with full documentation and many example snippets:
http://bazaar.launchpad.net/~sirver/ultisnips/trunk/view/head:/doc/UltiSnips.txt
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
UltiSnips-2.2.tar.gz 2.2 2012-09-01 7.0 Holger Rapp Smaller Bug fixes and improvements to shipped snippets.

- Support to silence Python-not-found warnings. *UltiSnips-python-warning*
- Matchit support for snippet files.
- Improvements to syntax file.
- Various smaller bug fixes.
- New command to manually add a filetype to the list for the current
  buffer. *:UltiSnipsAddFiletypes*
- New or improved snippets: all, snippets, haskell, bindzone, python, golang,
  json, html, coffee, coffee_jasmine, javascript_jasmine, ruby, php,
  markdown.
UltiSnips-2.1.tar.gz 2.1 2012-02-14 7.0 Holger Rapp This brings two small features related to ${VISUAL} which was introduce in 2.0: access to the content in python code via snip.v and transformations: ${VISUAL/foo/bar/g}. As expected, 2.0's new features introduced new bugs as, all known are fixed in 2.1.

- Python interpolation access to text from visual selection via snip.v.
- Support for transformations of ${VISUAL} texts.
- New or improved snippets: python, tex, texmath, ruby, rails, html, django
UltiSnips-2.0.tar.gz 2.0 2012-02-05 7.0 Holger Rapp Significant rewrite with new features and less bugs. It also has some minor backwards incompatible changes marked below.

- Backwards incompatible change: Support for normal mode editing. Snippets
  are no longer exited when leaving insert mode but only by leaving the
  text span of the snippets. This allows usage of normal mode commands and
  autoformatting. It also increases compatibility with other plugins.
- Backwards incompatible change: Changed glob patterns for snippets to
  behave more like Vim *UltiSnips-adding-snippets*
- Backwards incompatible change: Zero Tabstop is no longer removed in
  nested snippets
- Support for ${VISUAL:default text} placeholder. *UltiSnips-visual-placeholder*
- Improved handling of utf-8 characters in files and snippet definitions.
- Full support for :py3. UltiSnips now works with python >= 2.6 or >= 3.2.
- New or improved snippets: python, all
UltiSnips-1.6.tar.gz 1.6 2011-12-30 7.0 Holger Rapp Bug fix release. We also accept contributions on GitHub now (main development stays on launchpad though): https://github.com/SirVer/ultisnips/

- Significant speed improvements and a few bugs fixed.
- Better handling of non ASCII chars in snippets by assuming UTF-8 encoding
  when no other information is available.
- Contributions for UltiSnips are now also accepted on GitHub: https://github.com/SirVer/ultisnips/
- New or improved snippets: ruby, rails, xhtml
UltiSnips-1.5.tar.gz 1.5 2011-09-24 7.0 Holger Rapp This is mainly a bug-fix release. Very little user visible changes.

- Some critical bug fixes for new vim versions.
- New or improved snippets: tex, texmath, python, jinja2, go, puppet, xhtml
- Configuration of search path for snippets *UltiSnips-snippet-search-path*
- New parser implementation: A little faster, more flexible and less bugged.

UltiSnips-1.4.tar.gz 1.4 2011-07-17 7.0 Holger Rapp This release packs a bunch of new features and a lot of bug fixes. It also comes with new snippets and for the first time ever: windows support.

- New or improved snippets: php, html, djangohtml, mako, lua
- Snippets are now listed alphabetically by their trigger, no longer in
  order of appearance
- Snippet files are now automatically reloaded when they change.
- Support for other directory names for snippets beside
  "UltiSnips" *UltiSnips-snippet-search-path*
- Errors are now shown in a scratch window.
- Now fully supports Windows with python >= 2.6. UltiSnips should now work
  on all systems that Vim runs on.
- a syntax file was added for snippets files with nice highlighting.
- snippets definition files now have the filetype 'snippets'. It used to be
  'snippet'.
UltiSnips-1.3.tar.gz 1.3 2011-02-14 7.0 Holger Rapp UltiSnips is becoming a community project, the ChangeLog tells the story:

- Erlang snippets (g0rdin)
- Other VimScripts can now define and immediately expand anonymous snippets
  ( *UltiSnips_Anon* ) (Ryan Wooden)
- Other VimScripts can now define new snippets via a function
  ( *UltiSnips_AddSnippet* ) (Ryan Wooden)
- New Snippets for eruby and rails (Ches Martin).
- A new Option 't' has been added to snippets that avoid expanding tabstops.
  Be also more consistent with how indenting is handled. (Ryan Wooden)
- Added a ftplugin script for .snippets files. Syntax highlighting still
  missing. (Rupa Deadwyler)
- Added UltiSnipsReset and UltiSnipsEdit (Idea by JCEB)
UltiSnips-1.2.tar.gz 1.2 2010-08-24 7.0 Holger Rapp - many bugs were fixed
- smode mappings for printable characters are now removed before expanding a
  snippet. This is configurable. *UltiSnips-warning-smappings*
- all shipped snippets are now fully compatible with UltiSnips
- added support for global snippets which enhance python interpolation even
  more *UltiSnips-globals*
- added support for multi word and regular expression triggers. Very
  powerful in combination with python interpolation.
- Python interpolation became much more powerful *UltiSnips-python*
- added support for clearsnippets command *UltiSnips-clearing-snippets*
- added support for option w which is a little more strict than i.
- added support for listing of valid triggers. Defaults to <c-tab>.
- added support for option i (inword expansion)
- extends keyword is now supported on the first line of snippet files. This makes it easy to
       define special cases, for example cpp extends c: a cpp trigger is useless
       in c, but a c trigger is valuable for cpp.
- UltiSnips now adheres to expandtab and tabstop options of vim
UltiSnips-1.1.tar.gz 1.1 2009-07-21 7.0 Holger Rapp Made triggers configurable. You can also use the same trigger for expanding and tabbing. The TextMate configuration <tab> and <s-tab> is now possible.
Conditional Inserts can now be nested
Added support for b option. This only considers a snippet at the beginning of a line ( *UltiSnips-adding-snippets* )
Added support for ! option. This overwrites previously defined snippets with the same tab trigger ( *UltiSnips-adding-snippets* )
Support for dotted filetype syntax. Now snippets for more than one filetype can be active ( *UltiSnips-adding-snippets* )
Minor bug fixing.
UltiSnips-1.0.tar.gz 1.0 2009-07-16 7.0 Holger Rapp Initial upload
ip used for rating: 54.234.42.16

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo