5

I would like to make the snippets in js-mode available in web-mode.

There is no too many snippets in web-mode. What should I do to use javascript or HTML snippets in web-mode?

ppn029012
  • 580
  • 1
  • 6
  • 20

1 Answers1

3

Inside the snippets folder of web-mode, you can create a file called .yas-parents and just put the modes you want to include into web-mode, in your case, js-mode.

Several other modes use the same structure, for instance, most programming language modes have the prog-mode as parent (which contains generic stuff programmers use such as TODOs)

Henrique Jung
  • 1,408
  • 1
  • 15
  • 23
  • Is there a way to more finely control which snippets are loaded in web-mode? For example, there's no reason to load ERB snippets when editing a JavaScript file, but you can use web-mode for both. (Maybe this should be a separate question.) – Patrick Brinich-Langlois Jan 04 '16 at 04:00
  • I don't know how to do that. But as I understand `web-mode` is for files that contains several web-related languages (such as PHP, JS, etc). Why don't you use `js-mode` for files that are purely JavaScript? – Henrique Jung Jan 04 '16 at 16:45
  • @PatrickBrinich-Langlois See https://emacs.stackexchange.com/questions/48332/yasnippets-for-active-web-mode-engine. – Tobias Apr 08 '19 at 13:34