]> code.delx.au - gnu-emacs-elpa/blob - doc/index.org
remove erroneous #+BEGIN/END_QUOTE
[gnu-emacs-elpa] / doc / index.org
1 #+TITLE: Yet another snippet extension
2 #+OPTIONS: toc:1
3 #+STARTUP: showall
4
5 #+SETUPFILE: org-setup.inc
6
7 * Quick start
8
9 *YASnippet* is a template system for Emacs. It allows you to type an
10 abbreviation and automatically expand it into function templates. Bundled
11 language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML,
12 CSS and more. The snippet syntax is inspired from TextMate's syntax, you can
13 even [[#import-textmate][import most TextMate snippets]]
14
15 YASnippet is an original creation of [[http://pluskid.lifegoo.org][pluskid]] who also wrote its predecessor
16 [[http://code.google.com/p/smart-snippet][smart-snippet]].
17
18 ** Watch a demo
19
20 On [[http://www.youtube.com/watch?v=ZCGmZK4V7Sg][youtube]].
21
22 ** Installation
23
24 Clone this repository somewhere
25
26 #+begin_example
27 $ cd ~/.emacs.d/plugins
28 $ git clone https://github.com/capitaomorte/yasnippet
29 #+end_example
30
31 Add the following in your =.emacs= file:
32
33 #+begin_src emacs-lisp :exports code
34 (add-to-list 'load-path
35 "~/.emacs.d/plugins/yasnippet")
36 (require 'yasnippet)
37 (yas-global-mode 1)
38 #+end_src
39
40 Add your own snippets to =~/.emacs.d/snippets= by placing files there or
41 invoking [[sym:yas-new-snippet][=yas-new-snippet=]].
42
43 ** Import textmate snippets (rails example)
44 :PROPERTIES:
45 :CUSTOM_ID: import-textmate
46 :END:
47
48 YASnippet lets you use TextMate bundles directly:
49
50 #+begin_example
51 $ cd ~/.emacs.d/plugins
52 $ git clone https://github.com/capitaomorte/yasnippet
53 $ cd yasnippet
54 $ git submodule init
55 $ git submodule update
56 $ gem install plist trollop
57 $ rake convert_bundles # will convert ruby, rails and html bundles from drnic
58 #+end_example
59
60 Then, in your =.emacs= file
61
62 #+begin_example
63 (add-to-list 'load-path
64 "~/.emacs.d/plugins/yasnippet")
65 (require 'yasnippet)
66 (setq yas-snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/extras/imported"))
67 (yas-global-mode 1)
68 #+end_example
69
70 Open some rails file (model, app, etc) and start using the textmate
71 snippets. Consider that this is a work-in-progress and many snippets/commands
72 might not work. Patches welcome!
73
74 ** Contributing snippets
75
76 Please *do not ask me* to add snippets to the default collection under
77 =/snippets=. This collection is considered frozen. By customizing
78 [[sym:yas-snippet-dirs][=yas-snippet-dirs=]] you can point yasnippet to good
79 snippet collections out there.
80
81 The =extras/textmate-import.rb= tool can import many actual Textmate
82 snippets. I'm focusing on developing it and the accompanying =yas-setup.el=
83 files that guide it with more difficult importations. The idea is to deprecate
84 =/snippets= and replace it with =extras/imported=.
85
86 ** Documentation
87
88 The documentation has been split into separate parts:
89
90 1. [[file:snippet-organization.org][Organizing Snippets]]
91 Describes ways to organize your snippets in the hard disk.
92
93 2. [[file:snippet-expansion.org][Expanding Snippets]]
94 Describes how YASnippet chooses snippets for expansion at point.
95
96 Maybe, you'll want some snippets to be expanded in a particular mode,
97 or only under certain conditions, or be prompted using =ido=, etc...
98
99 3. [[file:snippet-development.org][Writing Snippets]]
100 Describes the YASnippet definition syntax, which is very close (but
101 not equivalent) to Textmate's. Includes a section about converting
102 TextMate snippets.
103
104 4. [[file:snippet-menu.org][The YASnippet menu]]
105 Explains how to use the YASnippet menu to explore, learn and modify
106 snippets.
107
108 5. [[file:snippet-reference.org][YASnippet Symbol Reference]]
109 An automatically generated listing of all YASnippet commands,
110 (customization) variables, and functions.
111
112 ** Bugs, discussion, contributions, etc
113
114 If you think you've found a bug, please report it on [[https://github.com/capitaomorte/yasnippet/issues][the GitHub issue tracker]]
115 (please **do not** submit new issues to the old [[http://code.google.com/p/yasnippet/issues/list][googlecode tracker]]).
116
117 If you run into problems using YASnippet, or have snippets to contribute,
118 post to the [[http://groups.google.com/group/smart-snippet][yasnippet forum]]. Thank you very much for using YASnippet!
119
120 # Local Variables:
121 # mode: org
122 # fill-column: 80
123 # coding: utf-8
124 # End: