Important: This documentation applies to the SVN trunk of YASnippet, which you get here. Documentation for other versions can be found here.
Contents
YASnippet is a template system for Emacs. It allows you to type a abbreviation and automatically expand the abbreviation into function templates.
Bundled language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more.
The snippet syntax is inspired from TextMate's syntax, you can even import import most TextMate templates to YASnippet.
YASnippet is a re-write of the extension smart-snippet. Both are original creations of pluskid.
Watch the demo at YouTube (download a higher resolution version: yasnippet.avi).
There are two archives of YASnippet. One is a single file compiled “bundle”, and the other is normal. If all you need is to use the built-in templates, download the bundle one. If you want to add your own templates, download the normal one.
That's it. Now open any one of your language file, you'll see a menu YASnippet. you can pull the menu to insert a template. Or, you can type the pre-defined abbrev and press TAB to expand it.
To have Emacs load YASnippet automatically when it starts, put the following in your ~/.emacs file:
(add-to-list 'load-path "~/.emacs.d/plugins") (require 'yasnippet-bundle)
For full install of the normal archive, just download and unpack the latest yasnippet-x.y.z.tar.bz2. You'll get a directory named yasnippet-x.y.z, put it in your ~/.emacs.d/plugins and add the following in your .emacs file:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-x.y.z") (require 'yasnippet) ;; not yasnippet-bundle (yas/initialize) (yas/load-directory "~/.emacs.d/plugins/yasnippet-x.y.z/snippets")
Please refer to the documentation for full customization, or use the customization group.
Since version 0.6, YASnippet contains more functionality. You don't need to know all of it to use it successfully, but you it can improve your snippeting experience.
Hence this section has been split into separate documents:
Describes ways to organize your snippets in the hard disk (or not organize them at all and just use yasnippet-bundle.el.
Describes how YASnippet chooses snippets for expansion at point.
Maybe, you'll want some snippets to be expanded in a particular mode, or only under certain conditions, or be prompted using ido, etc...
Describes the YASnippet definition syntax, which is very close (but not equivalent) to Textmate's. Includes a section about converting TextMate snippets.
Explains how to use the YASnippet menu to explore and learn new snippets.
Thank you very much for using YASnippet!