Skip to content



YASnippets uses plain text templates and so are very easy to learn and write. Snippets are specific to an Emacs major mode. They include tab stops, placoders with default values and markers to ensure correct indentation.

Yasnippets can also execute Elisp code, opening up a large number of Emacs functions to use within a snippet.

Spacemacs automatically includes snippets for many programming languages and text formats, including snippets for Clojure.

Take a look at how to write your own snippets and the custom snippets created by Practicalli

Configure yasnippetλ︎

The auto-completion layer adds yasnippet and the official snippet collection, yasnippet-snippets.

Add auto-completion to the dotspacemacs-configuration-layers list in .spacemacs

The clojure layer providing additional snippet templates from the clojure-snippets package.

!!! Hint::practicalli/spacemacs.d includes auto-completion configuration

Snippets in Auto-completion popupsλ︎

Snippets can be included in the auto-complete pop-up menu.

Spacemacs - Snippets - Web html link

Tab to navigate through the list of menu items.

Enter to select the snippet and add the template to the buffer.

Add the layer variable auto-completion-enable-snippets-in-popup t to the auto-completion layer in .spacemacs.

Practicalli also recommends adding auto-completion-enable-sort-by-usage t to show the most commonly used snippets at the top of the auto-completion pop-up menu.

(auto-completion :variables
                 auto-completion-enable-help-tooltip t
                 auto-completion-enable-snippets-in-popup t
                 auto-completion-enable-sort-by-usage t)

Snippet save locationsλ︎

Snippets are saved in ~/.emacs.d/private/snippets/.

When ~/.spacemacs.d is used for the Spacemacs configuration, snippets are saved in ~/.spacemacs.d/snippets/ directory.

Each snippet is saved in its own file, named after the alias of the snippet. The snippet file is located in a directory named after the Emacs major mode it belongs to.

A snippet called wip for Clojure has a file name wip and is in saved in directory named clojure.