August Feng

Learning yasnippets package

Creating snippets

The command yas-new-snippet will open a form for creating snippets.

The # name: and # key: fields describe the name of the snippet, and the abbreviation of the snippets before expansion.

Authoring snippets

embedded lisp code in template

Wrap the lisp code with `. This will be evaluated upon expansion.

avoiding auto indentations

The leading space before $2 is deleted when the template is inserted. We need to use the directive # expand-env: ((yas-indent-line 'fixed)) to avoid that.

$1

$0

Viewing snippets

individual snippets

We can visit individual snippets with the M-x yas/visit-snippet-file command.

snippet directories

The top-level snippet directories is configured with the yas-snippet-dirs variable.

The directory is organized by major modes and their applicable snippets.