Add personal snippets
masterYou can add your own snippets to YASnippet by:
- Placing snippet files in your configured snippet directory (e.g.,
~/.emacs.d/snippets). - Invoking the
yas-new-snippetcommand.
repository·master·Indexed 25 days ago
https://github.com/joaotavora/yasnippetA template system for Emacs that expands abbreviations into function templates. It supports various programming languages, is compatible with TextMate snippet syntax, and can be installed via Git, package-install, el-get, or MELPA.
You can add your own snippets to YASnippet by:
~/.emacs.d/snippets).yas-new-snippet command.YASnippet can be installed using standard Emacs package managers:
M-x list-packages to find and install it from GNU ELPA, GNU-devel ELPA, or MELPA.el-get to fetch the most recent version.To install YASnippet manually, clone the repository into your Emacs plugins directory and update your .emacs configuration to include the path, require the package, and enable global mode.
$ cd ~/.emacs.d/plugins
$ git clone --recursive https://github.com/joaotavora/yasnippet(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)If you do not want YASnippet enabled globally, avoid calling yas-global-mode. Instead, call yas-reload-all to load the snippet tables and then add yas-minor-mode to the hooks of specific major-modes where you want it active.
(yas-reload-all)
(add-hook 'prog-mode-hook #'yas-minor-mode)YASnippet does not bundle snippets by default. To use external snippet collections, point the yas-snippet-dirs variable to the relevant directories and then reload the snippets.
(setq yas-snippet-dirs
'("`~/.emacs.d/snippets" ;; personal snippets
"/path/to/some/collection/" ;; foo-mode and bar-mode snippet collection
"/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection
))
(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.