1 [![Build Status](https://travis-ci.org/capitaomorte/yasnippet.png)](https://travis-ci.org/capitaomorte/yasnippet)
5 **YASnippet** is a template system for Emacs. It allows you to
6 type an abbreviation and automatically expand it into function
7 templates. Bundled language templates include: C, C++, C#, Perl,
8 Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntax
9 is inspired from [TextMate's][textmate-snippets] syntax, you can
10 even [import](#import) most TextMate templates to
11 YASnippet. Watch [a demo on YouTube][youtube-demo].
13 [textmate-snippets]: http://manual.macromates.com/en/snippets
14 [youtube-demo]: http://www.youtube.com/watch?v=ZCGmZK4V7Sg
18 ## Install the most recent version
20 Clone this repository somewhere
22 $ cd ~/.emacs.d/plugins
23 $ git clone --recursive https://github.com/capitaomorte/yasnippet
25 Add the following in your `.emacs` file:
27 (add-to-list 'load-path
28 "~/.emacs.d/plugins/yasnippet")
32 Add your own snippets to `~/.emacs.d/snippets` by placing files there or invoking `yas-new-snippet`.
34 ## Install with `package-install`
36 In a recent emacs `M-x list-packages` is the recommended way to list and install packages.
37 [MELPA][melpa] keeps a very recent snapshot of YASnippet, see http://melpa.milkbox.net/#installing.
39 ## Install with el-get
41 El-get is a nice way to get the most recent version, too. See
42 https://github.com/dimitri/el-get for instructions.
44 ## Use `yas-minor-mode` on a per-buffer basis
46 To use YASnippet as a non-global minor mode, replace `(yas-global-mode 1)` with
47 `(yas-reload-all)` to load the snippet tables. Then add a call to
48 `(yas-minor-mode)` to the major-modes where you to enable YASnippet.
50 (add-hook 'prog-mode-hook #'yas-minor-mode)
52 # Where are the snippets?
56 Yasnippet no longer bundles snippets directly, but it's very easy to
59 If you git-cloned yasnippet with the `--recursive` option you'll also
60 download "git submodules" and find two subdirs under the main tree.
64 Points to [yasnippet-snippets][yasnippet-snippets] the snippet
65 collection of [AndreaCrotti](https://github.com/AndreaCrotti).
67 The default configuraiton already points to this dir, so to use
68 them, just make sure the submodule really was downloaded
69 (i.e. there are some files under `snippets/`)
73 Points to a github repo of the [yasmate][yasmate] tool, which is
74 dedicated to converting textmate bundles into yasnippet snippets.
76 To use these snippets you have to run the tool first, so
77 [see its doc][yasmate]), and then point the `yas-snippet-dirs`
78 variable to the `.../yasmate/snippets` subdir.
80 If you have a working ruby environment, you can probably get lucky
81 directly with `rake convert-bundles`.
83 Naturally, you can point `yas-snippet-dirs` to good snippet collections out
84 there. If you have created snippets for a mode, or multiple modes,
85 consider creating a repository to host them, then tell users that it
86 should be added like this to `yas-snippet-dirs`:
88 (setq yas-snippet-dirs
89 '("~/.emacs.d/snippets" ;; personal snippets
90 "/path/to/some/collection/" ;; foo-mode and bar-mode snippet collection
91 "/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection
92 "/path/to/yasnippet/snippets" ;; the default collection
95 (yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.
99 Please refer to the comprehensive [documentation][docs] for full
100 customisation and support. If you find a bug in the code or in the
101 documentation, please report it on [the GitHub issue tracker][issues].
103 ## Important note regarding bug reporting
105 Your bug reports are very valuable.
107 The most important thing when reporting bugs is making sure that we have
108 a way to reproduce the problem exactly like it happened to you.
110 To do this, we need to rule out interference from external factors
111 like other Emacs extensions or your own customisations.
113 Here's an example report that "sandboxes" an Emacs session just for
120 $ git clone https://github.com/capitaomorte/yasnippet.git yasnippet-bug
122 $ git log -1 --oneline
123 6053db0 Closes #527: Unbreak case where yas-fallback-behaviour is a list
124 $ HOME=$PWD emacs -L # This "sandboxes" your emacs, melpa configuration, etc
129 When I open a foo-mode file I can't expand foo-mode snippets!
131 I can't get yasnippet to load because frankinbogen!
134 Using `emacs -Q` or temporarily moving your `.emacs` init file to the side
135 is another way to achieve good reproducibility.
138 [another example](https://github.com/capitaomorte/yasnippet/issues/318)
139 of a bug report. It has everything needed for a successful analysis
140 and speedy resolution.
142 Also, don't forget to state the Emacs version (use `M-x emacs-version`) and
143 the yasnippet version you are using (if using the latest from github,
144 do `git log -1` in the dir).
146 Any more info is welcome, but don't just paste a backtrace or an error
147 message string you got, unless we ask for it.
149 There is also a [YASnippet google group][forum]. I will keep the group
150 open for reference and for discussion among users. Unfortunately I
151 can't guarantee a timely response, so maybe it's better to create a
152 github issue clearly marking your intent (user support/bug/feature
155 Finally, thank you very much for using YASnippet!
157 [docs]: http://capitaomorte.github.com/yasnippet/
158 [issues]: https://github.com/capitaomorte/yasnippet/issues
159 [googlecode tracker]: http://code.google.com/p/yasnippet/issues/list
160 [forum]: http://groups.google.com/group/smart-snippet
161 [melpa]: http://melpa.milkbox.net/
162 [yasmate]: http://github.com/capitaomorte/yasmate
163 [yasnippet-snippets]: http://github.com/AndreaCrotti/yasnippet-snippets