0

Recently, I asked about inserting a snippet with auto-insert-alist. That works but now I thought about using Snippets for blockquote, for inserting images, etc. I’ve been trying to install Yasnippets without success so far. I watched most of the Youtube videos but they all seem to do it differently.

So far I downloaded yasnippets and yasnippets-snippets`

enter image description here

and added

(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

to my .emacs file.

But when I go to emacs.d folder I don’t see a plugins folder or a yasnippet file.

enter image description here

Do I need to create those?

Can you help me install Yasnippets? Thanks!

2
  • Actually, as it is, this works. I created a new snippet and tested it and it worked. So, I don't need to create this directory "~/.emacs.d/plugins/yasnippet" ?
    – zeynel
    Aug 28, 2022 at 9:09
  • After you created the first snippet, to be saved it needed the directory to exist and created if for you. If you don't want to have files created everywhere by packages, use no-littering (github.com/emacscollective/no-littering)
    – Lhooq
    Aug 28, 2022 at 9:29

1 Answer 1

1

You should install yasnippet with M-x package-install RET yasnippet RET, and the expression (require 'yasnippet) is enough, the package is already installed in elpa folder; no need here for ~/.emacs.d/pluggins/yasnippet or load-path.

Also, you can install same way the package yasnippet-snippets, and require it in usual way (it is a collection of snippets created by someone else).

The problem(s) may apear if you want to create your snippets - for what I can see you already have a folder snippets created, there will go your new snippets, but you should place them inside other folders, corresponding to the mode in use. (e.g. in snippetscreate a folder python-mode and save there a new python snippet). You need to load those new snippets, so after requiring yasnippet-snippets add the expression (yas-reload-all) to have all ready for work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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