3 **YASnippet** is a template system for Emacs. It allows you to type an
4 abbreviation and automatically expand it into function
5 templates. Bundled language templates includes: C, C++, C#, Perl,
8 SQL, LaTeX, HTML, CSS and more. The snippet syntax is inspired from
9 [TextMate's][textmate-snippets] syntax, you can even
10 [import][import-docs] most TextMate templates to YASnippet. Watch
11 [a demo on YouTube][youtube-demo] or download a
12 [higher resolution version][high-res-demo]
14 [textmate-snippets]: http://manual.macromates.com/en/snippets
15 [import-docs]: http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html#importing-textmate-snippets
16 [youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg
17 [high-res-demo]: http://yasnippet.googlecode.com/files/yas_demo.avi
21 ## Install the most recent version
23 Clone this repository somewhere
25 $ cd ~/.emacs.d/plugins
26 $ git clone https://github.com/capitaomorte/yasnippet
28 Add the following in your `.emacs` file:
30 (add-to-list 'load-path
31 "~/.emacs.d/plugins/yasnippet")
35 Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas/new-snippet`.
37 ## Install yasnippet with el-get
39 El-get is a nice way to get the most recent version, too
41 See https://github.com/dimitri/el-get for instructions
43 ## Use `yas/minor-mode` on a per-buffer basis
45 To use yasnippet as a non-global minor mode, replace `(yas/global-mode 1)` with
46 `(yas/reload-all)` to load the snippet tables. Then add a call to
47 `(yas/minor-mode)` to the major-modes where you to enable yasnippet.
49 (add-hook 'prog-mode-hook
53 # Contributing snippets
55 Please do not ask me to add snippets to the default collection under
56 `/snippets`. This is considered frozen and by customizing
57 `yas/snippet-dirs` you can point yasnippet to good snippet collections
60 There is a tool `extras/textmate-import.rb` than can import many
61 actual Textmate snippets and there are
62 `extras/imported/*-mode/.yas-setup.el` files that can help it with the
63 more difficult importation.
65 I'm focusing on developping `textmate-import.rb` tool and the
66 `yas-setup.el` files. In the future `/snippets` snippets will be
67 deprecated and replaced with `extras/imported`.
69 Follow through the following example to start using these snippets for
70 rails development. It will convert `ruby`, `rails` and `html` bundles
71 from drnic's github repositories based on corresponding
72 `.yas-setup.el` files.
74 ## Using imported textmate snippets (rails example)
76 After cloning this repository to `~/.emacs.d/plugins/yasnippet`
78 cd ~/.emacs.d/plugins/yasnippet
81 gem install plist trollop
82 rake convert_bundles # will convert ruby, rails and html bundles from drnic
84 Then, in your .emacs file
86 (add-to-list 'load-path
87 "~/.emacs.d/plugins/yasnippet")
89 (setq yas/snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/plugins/yasnippet/extras/imported"))
92 Open some rails file (model, app, etc) and start using the textmate snippets.
93 Note thqt in the example above we abandon the default snippet collection on
94 `~/.emacs.d/plugins/yasnippet/snippets`
96 # Documentation, issues, etc
98 Please refer to the comprehensive [documentation] [docs] for full customization
99 and support. If you find a bug, please report it on
100 [the GitHub issue tracker][issues]. (please **do not** submit new issues to the old
101 [googlecode tracker][googlecode tracker])
103 If you run into problems using YASnippet, or have snippets to contribute, post
104 to the [yasnippet google group][forum]. Thank you very much for using YASnippet!
106 [docs]: http://capitaomorte.github.com/yasnippet/
107 [issues]: https://github.com/capitaomorte/yasnippet/issues
108 [googlecode tracker]: http://code.google.com/p/yasnippet/issues/list
109 [forum]: http://groups.google.com/group/smart-snippet