I'm a novice at emacs use in general, and new to spacemacs, so I'm hoping this is just a case of missing a trick or two. I am working in a symlinked app on Mac OSX, not in the terminal.

I have a pretty much stock config of spacemacs, added a few extra layers, in evil-mode. I'm trying to do some work with HTML, using web-mode, and it isn't behaving entirely as described:

If I type <li I get a dropdown menu that completes words, but doesn't complete the open/close tag (is this intended behaviour, or is it supposed to complete your selection if you make one?).

If I type <li></ it will autocomplete properly to <li></li>, matching indicated behaviour. I have tried setting web-mode-tag-auto-close-style to 2 in dotspacemacs/userconfig () per this answer to allow completion at opening tag closure instead of closure tag opening (i.e. <li> --> <li></li>) but have had no luck getting it to work. Am I putting it in the wrong place or using the wrong syntax?

If I type d/s/ as in the example it results in <d/> instead of the indicated <div><span>|</div></span>. Yet if I type d TAB s TAB it produces <d>s</d>| and if I then scroll back to s and hit TAB again, it produces <d><s></s></d> I have not been able to find more detailed information about this function of web-mode, am I using it incorrectly?



I'm not sure what's going on with (setq web-mode-tag-auto-close-style 2), but you can get auto-closing with </ as you noted, and also with the TAB key via emmet-mode (see below).

Emmet-mode auto-closing

You can get <div>|</div> with either

  • divTAB
  • div>TAB

...but not with <div>TAB


To get the behaviour you want with d/s/, you need to include the following setup code in your config:

(eval-after-load "web-mode"
  '(setq web-mode-enable-auto-expanding t))


Note that the Spacemacs html-layer includes emmet-mode ("zencoding") as well as web-mode, which gives you convenient shortcuts.1

1   The web-mode expanders will change the behaviour of emmet-mode shortcuts slightly, I doubt it will cause any problems.


web-mode-tag-auto-close-style got renamed to web-mode-auto-close-style in this commit https://github.com/fxbois/web-mode/commit/c17be6c4900fdfe4e996552efc39bdff782c6585

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.