sponsor Vim development Vim logo Vim Book Ad

snipMate : TextMate-style snippets for Vim

 script karma  Rating 6142/1821, Downloaded by 80538    Comments, bugs, improvements  Vim wiki

created by
Michael Sanders
 
script type
utility
 
description
snipMate.vim aims to be an unobtrusive, concise vim script that implements some of TextMate's snippets features in Vim. A snippet is a piece of often-typed text that you can insert into your document using a trigger word followed by a <tab>.

For instance, in a C file using the default installation of snipMate.vim, if you type "for<tab>" in insert mode, it will expand a typical for loop in C:

for (i = 0; i < count; i++) {

}

To go to the next item in the loop, simply <tab> over to it; if there is repeated code, such as the "i" variable in this example, you can simply start typing once it's highlighted and all the matches specified in the snippet will be updated.

Requires Vim 7 or higher.
For a quick introduction, see this screencast: http://vimeo.com/3535418
For more help see the documentation that comes with snipMate in ~/.vim/doc/snipMate.txt.

snipMate.vim has the following features among others:
  - The syntax of snippets is very similar to TextMate's, allowing easy conversion.
  - The position of the snippet is kept transparently (i.e., it does not use marks/placeholders inserted into the buffer), allowing you to escape out of an incomplete snippet, something particularly useful in Vim.
  - Variables in snippets are updated as-you-type.
  - Snippets can have multiple matches.
  - Snippets can be out of order. For instance, in a do...while loop, the condition can be added before the code.

Bug reports, feature requests, etc. are welcome and can be emailed to me or submitted on the issue tracker: http://code.google.com/p/snipmate/issues/list

If you would like to watch the development of this plugin, you can also follow it on github: http://github.com/msanders/snipmate.vim

Enjoy!
 
install details
unzip snipMate.zip -d ~/.vim (or equivalent, e.g. $HOME\vimfiles on Windows)

Keep in mind this will overwrite any files included with older versions of snipMate, including the default *.snippets files for the included filetypes. If you don't want your snippets overwritten, just name them name them differently than the default snippets, e.g. c-mysnips.snippets.

NOTE: remember to add ":filetype plugin on" to your .vimrc, otherwise snippets will not work! This is one of the most common issue new users face when trying snipMate.

Remember to run ":helptags ~/.vim/doc" to enable the help.
 

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
snipMate.zip 0.83 2009-07-13 7.0 Michael Sanders Fixed bug when leaving snippet for another buffer, having a variable at the end of a line in a snippet, or typing certain characters in select mode, and (finally) added support for <shift-tab> to go back a tab stop. Also added snippets for zsh (thanks israelchauca) and mako (thanks "iElectric"), and updated C, Obj-C, and C++ snippets.
snipMate.zip 0.82 2009-06-11 7.0 Michael Sanders Fixed a bug with <c-r><tab>, placeholders, or having more than 9 tab stops on the same line, and added a Python snippet for the lambda (thanks voyeg3r), as well as snippets for the Tcl (thanks israelchauca) and AutoIt (thanks Angel Ezquerra Moreu) filetypes.
snipMate.zip 0.81 2009-05-16 7.0 Michael Sanders Added syntax highlighting to show errors in snippet files, fixed typos in certain snippets, fixed a bug with "&" in placeholders, fixed a bug when canceling multi-snippets, and fixed a bug when inserting a new line in a snippet.
snipMate.zip 0.8 2009-05-03 7.0 Michael Sanders Added & fixed some snippets, and added a menu that displays all snippets for the current buffer when <c-r><tab> is typed in insert mode.

I've removed convertSnip.py from this release since most snippets should be converted by now; if you still need it, just grab it from an earlier release.
snipMate.zip 0.79 2009-04-14 7.0 Michael Sanders Added support for more than 9 tab stops, fixed typos in certain snippets, and cleaned up the code a bit.
snipMate.zip 0.78 2009-04-06 7.0 Michael Sanders Fixed bug with aliased filetypes (e.g. loading C snippets for Obj-C files), updating placeholders on separate lines, and extracting snippets on Windows. Also added a few more Python, C, and Obj-C snippets, and fixed some typos in the Latex and C++ snippets.
snipMate.zip 0.77 2009-03-30 7.0 Michael Sanders Fixed bug with single quotes (') in snippet triggers, and hyphenated global snippets (e.g., _-mysnips.snippets).
snipMate.zip 0.76 2009-03-29 7.0 Michael Sanders Fixed bug with extracting snippet files on Windows, folding, and a minor bug with supertab.
snipMate.zip 0.75 2009-03-27 7.0 Michael Sanders Added fix for hyphenated *.snippets files.
snipMate.zip 0.74 2009-03-26 7.0 Michael Sanders This release completely eliminates command-based snippets in favor of a new, easier to read & maintain syntax. A python script, convertSnip.py, has been included in this release to make it easier to migrate. For more information, see :h snippet-syntax; it's not very complicated, so it shouldn't take too much time to understand.

This release also fixes a number of bugs, including: support for supertab, special characters in snippet variables, the popup-menu, and adds support for hyphened snippet folders (e.g. snippets/c-snippets/ for C).
snipMate.zip 0.73 2009-03-15 7.0 Michael Sanders Fixed bug with redefinition of C++ snippets, fixed a bug when using the completion menu, added support for the 'shellslash' option (thanks Derek Wyatt), and added support for buffer-local snippets (thanks Meikel Brandmeyer).
snipMate.zip 0.72 2009-03-10 7.0 Michael Sanders Fixed a bug with variables inside placeholders (e.g. "${1:foo} ${2:$1bar}").
snipMate.zip 0.71 2009-03-09 7.0 Michael Sanders First and foremost, the code has been significantly re-factored; it is a bit longer now, but hopefully at the sake of being much easier to read and maintain.

This release also adds: support for file-based snippets, support for delimiters before snippet triggers (e.g., "bar.foo" could expand "foo"), and bug fixes.
snipMate.zip 0.6956 2009-02-25 7.0 Michael Sanders Forgot a backslash in the supertab.vim fix.
snipMate.zip 0.6955 2009-02-24 7.0 Michael Sanders Actually fixed the supertab bug (thanks Asher VanBrunt); also added some more Objective-C snippets, and fixed another bug with expanding snippets before text introduced in the previous version.
snipMate.zip 0.6954 2009-02-24 7.0 Michael Sanders Fixed a bug when expanding snippets with text after them, and a bug with expanding evals (`...`) that prevented substitutions containing "\=" such as substitute('foo', '.*', '\=toupper(submatch(0))') from working.

Also fixed another typo in the Python snippets, and supertab compatibility.
snipMate.zip 0.6942 2009-02-21 7.0 Michael Sanders Fixed some typos in LaTeX and Python snippets, and added a snippet for the HTML 5 doctype.

Also added support for cycling through completions using supertab, and using completions to expand placeholder text.

The indentation amount for 'expandtab' also now defaults to 'sw' if 'sts' is not set.
snipMate.zip 0.61803399 2009-02-16 7.0 Michael Sanders I apparently forgot to update the "Snip!" commands to "Snipp!" in the last version; this update takes care of that (thanks Martin Krauskopf for the bug report). The regex command to update these should actually be ":%s/exe \(.\)Snip\( \|!\)/exe \1Snipp\2".

This update also fixes a typo in the "def" ruby snippet (thanks Reza Jelveh & Jan Andersson).
snipMate.zip 0.6180339 2009-02-15 7.0 Michael Sanders Added support for 'virtualedit=all' and 'virtualedit=onemore'. Thanks Mikhail Daen for the bug report.
snipMate.zip 0.618033 2009-02-14 7.0 Michael Sanders Fixed another bug concerning loading a filetype more than once.
snipMate.zip 0.61803 2009-02-13 7.0 Michael Sanders Fixed some other bugs for compatibility with supertab.vim and 'set expandtab' and added check to ensure snippets are not loaded twice.

I also changed the "Snip" command to "Snipp" to maintain compatibility with vimscript #244 (imaps.vim). Unfortunately this breaks backward compatibility; to update any snippets you have added, just execute this regex on the appropriate files: ":%s/exe \(.\)Snip /exe \1Snipp /g"
snipMate.zip 0.6180 2009-02-13 7.0 Michael Sanders Added support for 'set expandtab', supertab.vim, and fixed some bugs.
snipMate.zip 0.42 2009-02-11 7.0 Michael Sanders Initial upload
ip used for rating: 50.19.206.49

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