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
The auto-completion layer adds yasnippet and the official snippet collection, yasnippet-snippets.
auto-completion to the
dotspacemacs-configuration-layers list in
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.
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
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
~/.spacemacs.d is used for the Spacemacs configuration, snippets are saved in
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