I want to have a way, to efficiently create new YaSnippet-snippets. YaSnippet has the functionality, that via pressing C-c C-n
one can create a new snippet. However, the empty new snippet is very basic. It looks something like this:
# -*- mode: snippet -*-
# name:
# key:
# --
When creating many similar snippets, which have headers, like this:
# -*- mode: snippet -*-
# name: foo
# key: foo
# group: math
# condition: (and (texmathp) 'auto)
# --
I need to type or copy everything every time I create a new snippet.
How can I create a Template for creating snippets, such that, when pressing C-c C-n
the advanced heading gets inserted?
I looked through the YaSnippet-manual and did not find anything appropriate.
Ideally I would have different templates, such that pressing C-c C-n
prompts me for a key, to chose which template to use.
(It would be even better when the snippet after saving with C-c C-c
then gets put in the correct subdirectory of the snippets folder ("latex-mode" in this case) without asking in which to put it, but this is optional, it's just 1 keystroke everytime, which is not that bad.)
yasnippet.el
library foryas-new-snippet
states: "Lets you create a new snippet file in the correct subdirectory ofyas-snippet-dirs
, according to the active major mode." github.com/joaotavora/yasnippet/blob/master/yasnippet.el#L85 If the snippet is not being created in the folder that you expect (which must also coincide with the statement in the library commentary, supra), then check the value of the variableyas-snippet-dirs
.... You can inspect the value of a variable withC-h v
.