2

I'm struggling a bit with yasnippet. My question must be very basic but I would like to modify some snippets but I can't locate them. I have for example a snippet style for html-mode but it does not appear where it should be that is either under :

~/.emacs.d/elpa/yasnippet

or

~/.emacs.d/snippets

My config is the following:

(add-to-list 'load-path
         "~/.emacs.d/elpa/yasnippet-20160801.1142")
(require 'yasnippet)
(yas-global-mode 1)
(add-to-list 'yas-snippet-dirs "~/.emacs.d/snippets")

Any would be appreciated!

2

Considering your configuration, using elpa, they are located in ~/.emacs.d/elpa/yasnippet-20160801.1142/snippets.

Your custom snippets should be at ~/.emacs.d/snippets so they don't get overwritten in each update. Also check the value of the variable yas-snippets-dirs with Ctr-h v yas-snippets-dir.

2

If you want to edit a snippet from the mode you are in just press the standard commands :

C-c & C-v to view an existing snippet (you should know what name it has)

or

C-c & C-n to create a new snippet for the mode you're in.

In this way you don't have to care about where the snippets are located, YASnippet should do that automatically.

You can also open existing/new snippets by clicking on the menu bar YASnippet (if you're using the GUI).

I hope this could help you.

0

Try (setq yas-snippet-dirs '("~/.emacs.d/snippets"))

When you miss a snippet, that you've already created, use yas-reload-all.

And you don't need the first line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.