- Notifications
You must be signed in to change notification settings - Fork0
mforbes/yasnippet
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
YASnippet is a template system for Emacs. It allows you totype an abbreviation and automatically expand it into functiontemplates. Bundled language templates include: C, C++, C#, Perl,Python, Ruby, SQL, LaTeX, HTML, CSS and more. The snippet syntaxis inspired fromTextMate's syntax, you canevenimport most TextMate templates toYASnippet. Watcha demo on YouTube or download ahigher resolution version.
Clone this repository somewhere
$ cd ~/.emacs.d/plugins$ git clone https://github.com/capitaomorte/yasnippet
Add the following in your.emacs
file:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")(require 'yasnippet)(yas-global-mode 1)
Add your own snippets to~/.emacs.d/snippets
by placing files there or invokingyas-new-snippet
.
In a recent emacsM-x list-packages
is the recommended way to list and install packages.MELPA keeps a very recent snapshot of YASnippet, seehttp://melpa.milkbox.net/#installing.
El-get is a nice way to get the most recent version, too. Seehttps://github.com/dimitri/el-get for instructions. Be sure to install the"master" branch since the 3.x series still use the old googlecode code, base.Consider using this "local" recipe.
(push '(:name yasnippet :website "https://github.com/capitaomorte/yasnippet.git" :description "YASnippet is a template system for Emacs." :type github :pkgname "capitaomorte/yasnippet" :features "yasnippet" :compile "yasnippet.el") el-get-sources)
To use YASnippet as a non-global minor mode, replace(yas-global-mode 1)
with(yas-reload-all)
to load the snippet tables. Then add a call to(yas-minor-mode)
to the major-modes where you to enable YASnippet.
(add-hook 'prog-mode-hook '(lambda () (yas-minor-mode)))
Pleasedo not open pull requests or ask me to add snippets toYASnippet.
The bundled collection under/snippets
is considered frozen:Iwill not add more snippets to it.
You can pointyas-snippet-dirs
to good snippet collections outthere. If you have created snippets for a mode, or multiple modes,consider creating a repository to host them, then tell users that itshould be added like this toyas-snippet-dirs
:
(setq yas-snippet-dirs '("~/.emacs.d/snippets" ;; personal snippets "/path/to/some/collection/" ;; just some foo-mode snippets "/path/to/some/othercollection/" ;; some more foo-mode and a complete baz-mode "/path/to/yasnippet/snippets" ;; the default collection ))(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.
There is a toolextras/textmate-import.rb
than can import manyactual TextMate snippets. These can be quite complex so theextras/imported/*-mode/.yas-setup.el
files help it with the moredifficult importation.
I'm focusing on developingtextmate-import.rb
tool and someyas-setup.el
files. In the future/snippets
snippets will bedeprecated and might be replaced withextras/imported
.
To start usingdrnic's snippets for railsdevelopment, follow this example. It will convertruby
,rails
andhtml
bundles from github repositories. The importation will beguided by the.yas-setup.el
files.
After cloning this repository to~/.emacs.d/plugins/yasnippet
cd ~/.emacs.d/plugins/yasnippetgit submodule initgit submodule updategem install plist trolloprake convert_bundles # will convert ruby, rails and html bundles
Then, in your.emacs
file
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")(require 'yasnippet)(setq yas-snippet-dirs '("~/.emacs.d/snippets" "~/.emacs.d/plugins/yasnippet/extras/imported"))(yas-global-mode 1)
Open some rails file (model, app, etc) and start using the textmatesnippets. Note that in the example above we have abandoned thedefault snippet collection on~/.emacs.d/plugins/yasnippet/snippets
Please refer to the comprehensive (albeit slightly outdated)documentation for full customizationand support. If you find a bug, please report it onthe GitHub issue tracker. (pleasedo not submit new issues to the oldgooglecode tracker)
If you think have found a bug, please report it clearly. Yasnippetdoes have (lots of) bugs and your reports are very valuable. Here'sagreat exampleof a bug report. It has everything needed for a sucessfull analysis andspeedy resolution:
Before reporting try to reproduce the bugwithout your usual.emacs
(or whatever startup file you use). Do so either by startingemacs from the command line with the-Q
switch, or by temporarilymoving away your.emacs
and creating a new smaller one just forreproducing the bug. Paste that file in your bug report. Paste any sequenceof relevant shell commands before you launch Emacs.
Then, describe steps taken to reproduce from anend-user perspective. Try to be as unambiguous as possible.
Also, don't forget to state the Emacs version (useM-x emacs-version
) andthe yasnippet version you are using (if using the latest from github,dogit log -1
in the dir).
Any more info is welcome, but don't just paste a backtrace or an errormessage string you got. I'm not saying your analysis might not beuseful but following the instructions above immediately gives me aclear picture of what is happening.
There is also aYASnippet google group. I will keep the groupopen for reference and for discussion among users, unfortunately Ican't guarantee a timely response, so maybe creating a github issueclearly marking your intent (user support/bug/feature request).
Finally, thank you very much for using YASnippet!