5 Snippet definitions are stored in files in the filesystem. Unless you
6 use the simpler [[index.html@installation][bundle version]]), these are
7 arranged so that YASnippet can load them into /snippet tables/. The
8 triggering mechanisms (see [[snippet-expansion.html][Expanding
9 snippets]]) will look up these snippet tables and (hopefully) expand the
12 The non-bundle version of YASnippet, once unpacked, comes with a full
13 directory of snippets, which you can copy somewhere and use. You can
14 also create or download more directories.
16 Once these directories are in place reference them in the variable
17 =yas-root-directory= and load them with =yas-load-directory=:
19 The point in using =yas-root-directory= (as opposed to calling
20 =yas-load-directory= directly) is considering "~/emacs.d/mysnippets" for
21 snippet development, so you can use commands like =yas-new-snippet= and
22 others described in section [[snippet-development.html][Writing
25 You can make this variable a list and store more items into it:
27 In this last example, the all the directories are loaded and their
28 snippets considered for expansion. However development still happens in
29 the first element, "~/emacs.d/mysnippets".
31 ** Organizing snippets
33 Once you've setup =yas-root-directory= , you can store snippets inside
34 sub-directories of these directories.
36 Snippet definitions are put in plain text files. They are arranged by
37 sub-directories, and the snippet tables are named after these
40 The name corresponds to the Emacs mode where you want expansion to take
41 place. For example, snippets for =c-mode= are put in the =c-mode=
44 *** The =.yas.parents= file
46 It's very useful to have certain modes share snippets between
47 themselves. To do this, choose a mode subdirectory and place a
48 =.yas-parents= containing a whitespace-separated list of other mode
49 names. When you reload those modes become parents of the original mode.
51 *** The =.yas-make-groups= file
53 [[images/menu-groups.png]]
55 If you place an empty plain text file =.yas-make-groups= inside one of
56 the mode directories, the names of these sub-directories are considered
57 groups of snippets and [[snippet-menu.html][The YASnippet Menu]] is
58 organized much more cleanly, as you can see in the image.
60 Another alternative way to achieve this is to place a =# group:=
61 directive inside the snippet definition. See
62 [[snippet-development.html][Writing Snippets]].
66 The most convenient way to define snippets for YASnippet is to put them
67 in a directory arranged by the mode and use =yas-load-directory= to load
70 However, this might slow down the Emacs start-up speed if you have many
71 snippets. You can use =yas-define-snippets= to define a bunch of
72 snippets for a particular mode in an Emacs-lisp file.
74 Since this is hard to maintain, there's a better way: define your
75 snippets in directory and then call =M-x yas-compile-bundle= to compile
76 it into a bundle file when you modified your snippets.
78 The release bundle of YASnippet is produced by =yas-compile-bundle=. The
79 bundle uses =yas-define-snippets= to define snippets. This avoids the IO
80 and parsing overhead when loading snippets.
82 Further more, the generated bundle is a stand-alone file not depending
83 on =yasnippet.el=. The released bundles of YASnippet are all generated
86 See the internal documentation for these functions
88 - =M-x describe-function RET yas-define-snippets RET=
89 - =M-x describe-function RET yas-compile-bundle RET=.
91 ** Customizable variables
93 *** =yas-root-directory=
95 Root directory that stores the snippets for each major mode.
97 If you set this from your .emacs, can also be a list of strings, for
98 multiple root directories. If you make this a list, the first element is
99 always the user-created snippets directory. Other directories are used
100 for bulk reloading of all snippets using =yas-reload-all=
102 *** =yas-ignore-filenames-as-triggers=
104 If non-nil, don't derive tab triggers from filenames.
106 This means a snippet without a =# key:= directive wont have a tab