3 **YASnippet** is a template system for Emacs. It allows you to
4 type an abbreviation and automatically expand it into function
5 templates. Bundled language templates include: C, C++, C#, Perl,
6 Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax
7 is inspired from [TextMate's][textmate-snippets] syntax, you can
8 even [import][import-docs] most TextMate templates to
9 YASnippet. Watch [a demo on YouTube][youtube-demo] or download a
10 [higher resolution version][high-res-demo].
12 [textmate-snippets]: http://manual.macromates.com/en/snippets
13 [import-docs]: http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html#importing-textmate-snippets
14 [youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg
15 [high-res-demo]: http://yasnippet.googlecode.com/files/yas_demo.avi
19 ## Install the most recent version
21 Clone this repository somewhere
23 $ cd ~/.emacs.d/plugins
24 $ git clone https://github.com/capitaomorte/yasnippet
26 Add the following in your `.emacs` file:
28 (add-to-list 'load-path
29 "~/.emacs.d/plugins/yasnippet")
33 Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas-new-snippet`.
35 ## Install with `package-install`
37 In a recent emacs `M-x list-packages` is the recommended way to list and install packages.
38 [MELPA][melpa] keeps a very recent snapshot of YASnippet, see http://melpa.milkbox.net/#installing.
40 ## Install with el-get
42 El-get is a nice way to get the most recent version, too. See
43 https://github.com/dimitri/el-get for instructions. Be sure to install the
44 "master" branch since the 3.x series still use the old googlecode code, base.
45 Consider using this "local" recipe.
47 (push '(:name yasnippet
48 :website "https://github.com/capitaomorte/yasnippet.git"
49 :description "YASnippet is a template system for Emacs."
51 :pkgname "capitaomorte/yasnippet"
53 :compile "yasnippet.el")
56 ## Use `yas-minor-mode` on a per-buffer basis
58 To use YASnippet as a non-global minor mode, replace `(yas-global-mode 1)` with
59 `(yas-reload-all)` to load the snippet tables. Then add a call to
60 `(yas-minor-mode)` to the major-modes where you to enable YASnippet.
62 (add-hook 'prog-mode-hook
66 # (NOT) Contributing snippets
68 Please **do not** open pull requests or ask me to add snippets to
71 The bundled collection under `/snippets` is considered frozen: **I
72 will not add more snippets to it**.
74 You can point `yas-snippet-dirs` to good snippet collections out
75 there. If you have created snippets for a mode, or multiple modes,
76 consider creating a repository to host them, then tell users that it
77 should be added like this to `yas-snippet-dirs`:
79 (setq yas-snippet-dirs
80 '("~/.emacs.d/snippets" ;; personal snippets
81 "/path/to/some/collection/" ;; just some foo-mode snippets
82 "/path/to/some/othercollection/" ;; some more foo-mode and a complete baz-mode
83 "/path/to/yasnippet/snippets" ;; the default collection
86 (yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.
88 # Importing TextMate snippets
90 There is a tool `extras/textmate-import.rb` than can import many
91 actual TextMate snippets. These can be quite complex so the
92 `extras/imported/*-mode/.yas-setup.el` files help it with the more
93 difficult importation.
95 I'm focusing on developing `textmate-import.rb` tool and some
96 `yas-setup.el` files. In the future `/snippets` snippets will be
97 deprecated and might be replaced with `extras/imported`.
99 ## Example importation of rails snippets
101 To start using [drnic's](https://github.com/drnic) snippets for rails
102 development, follow this example. It will convert `ruby`, `rails` and
103 `html` bundles from github repositories. The importation will be
104 guided by the `.yas-setup.el` files.
106 After cloning this repository to `~/.emacs.d/plugins/yasnippet`
108 cd ~/.emacs.d/plugins/yasnippet
111 gem install plist trollop
112 rake convert_bundles # will convert ruby, rails and html bundles
114 Then, in your `.emacs` file
116 (add-to-list 'load-path
117 "~/.emacs.d/plugins/yasnippet")
119 (setq yas-snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/plugins/yasnippet/extras/imported"))
122 Open some rails file (model, app, etc) and start using the textmate
123 snippets. Note that in the example above we have abandoned the
124 default snippet collection on `~/.emacs.d/plugins/yasnippet/snippets`
126 # Documentation, issues, etc
128 Please refer to the comprehensive (albeit slightly outdated)
129 [documentation][docs] for full customization
130 and support. If you find a bug, please report it on
131 [the GitHub issue tracker][issues]. (please **do not** submit new issues to the old
132 [googlecode tracker][googlecode tracker])
134 If you run into problems using YASnippet, or have snippets to contribute, post
135 to the [YASnippet google group][forum]. Thank you very much for using YASnippet!
137 [docs]: http://capitaomorte.github.com/yasnippet/
138 [issues]: https://github.com/capitaomorte/yasnippet/issues
139 [googlecode tracker]: http://code.google.com/p/yasnippet/issues/list
140 [forum]: http://groups.google.com/group/smart-snippet
141 [melpa]: http://melpa.milkbox.net/