# binding: header documented in the manual is the official method to do this. It's implemented using
emulation-mode-map-alists which means it will override any other major or minor mode keybindings, except for packages which also use
emulation-mode-map-alists, typically emulation packages like Evil.
I noticed it will work when you're in insert mode of Evil. When you're currently in normal mode, the keybinding will do nothing. -- I would like to bind it to the key
gl with keychord.
You could use something like:
(defun exand-yasnippet-foobar ()
"Expand the yasnippet named `foobar'."
(yas-expand-snippet (yas-lookup-snippet "foobar")))
And then bind
expand-yasnippet-foobar to some key in whatever keymap you like. Make sure your snippet includes a
# name: foobar header.
yas-lookup-snippet was added to yasnippet on August 3rd, 2015. For older versions it can be defined as
(defun yas-lookup-snippet (name &optional _mode noerror)
(let* ((yas-choose-tables-first nil) ; avoid prompts
(snippet (cl-find name (yas--all-templates
:key #'yas--template-name :test #'string=)))
(snippet (yas--template-content snippet))
(t (error "No snippet named: %s" NAME)))))