1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
=============================
Yet Another Snippet extension
=============================
.. _Organizing Snippets: snippet-organization.html
.. _Expanding Snippets: snippet-expansion.html
.. _Writing Snippets: snippet-development.html
.. _The YASnippet Menu: snippet-menu.html
.. contents::
**YASnippet** is a template system for Emacs. It allows you to type an
abbreviation and automatically expand it 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 <snippet-development.html#importing-textmate-snippets>`_
import most TextMate templates. YASnippet is a re-write of the
extension `smart-snippet`_. Both are original creations of `pluskid
<http://pluskid.lifegoo.org>`_.
.. _smart-snippet: http://code.google.com/p/smart-snippet/
Video Demo
==========
.. youtube:: 76Ygeg9miao
:align: right
Watch the `demo at YouTube
<http://www.youtube.com/watch?v=76Ygeg9miao>`_ (download a higher
resolution version: `yasnippet.avi
<http://yasnippet.googlecode.com/files/yasnippet.avi>`_).
Installation
============
There are two archives you can download. To quickly tryout YASnippet,
download the simpler "bundle" version. If you plan to modify the
bundled templates and/or build your own, download the "normal"
package.
Install with ``yasnippet-bundle.el``
------------------------------------
1. Download the latest ``yasnippet-bundle-x.y.z.el.tgz`` and unpack it.
2. You'll get a file named ``yasnippet-bundle.el``, put it under
``~/.emacs.d/plugins/`` (create the directory if not exists).
3. Open the file in Emacs, and type ``Alt+x eval-buffer``.
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 a *trigger key* then press ``TAB`` to expand it.
To have Emacs load YASnippet automatically when it starts, put the
following in your ``~/.emacs`` file:
.. sourcecode:: common-lisp
(add-to-list 'load-path
"~/.emacs.d/plugins")
(require 'yasnippet-bundle)
The `youtube video <http://www.youtube.com/watch?v=76Ygeg9miao>`_
demonstrates this quick installation.
Normal Install
--------------
To install YASnippet as a normal emacs package, download and unpack
the latest ``yasnippet-x.y.z.tar.bz2``. You'll get a directory named
``yasnippet-x.y.z``, which you can put it in your
``~/.emacs.d/plugins`` and add the following in your ``.emacs`` file:
.. sourcecode:: common-lisp
(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.
How to use YASnippet
====================
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:
1. `Organizing Snippets`_
Describes ways to organize your snippets in the hard disk (or not
organize them at all and just use ``yasnippet-bundle.el``.
2. `Expanding Snippets`_
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...
3. `Writing Snippets`_
Describes the YASnippet definition syntax, which is very close (but
not equivalent) to Textmate's. Includes a section about converting
TextMate snippets.
4. `The YASnippet menu`_
Explains how to use the YASnippet menu to explore, learn and modify
snippets.
Bugs, Contribution and Support
==============================
* If you find a bug, please report it at `Issue List
<http://code.google.com/p/yasnippet/issues/list>`_.
* If you have problem using YASnippet, or have some new ideas,
including snippets, please post to the `discussion group`_.
.. _discussion group: http://groups.google.com/group/smart-snippet
.. _wish list: http://code.google.com/p/yasnippet/wiki/WishList
Thank you very much for using YASnippet!
.. LocalWords: YASnippet SQL LaTeX CSS yasnippet el eval html ido RET wiki
|