With the default HTML mode as of Emacs 24.4, you can get the same behavior as Sublime Text (automatic insertion of the closing tag if you type </
) by putting the following line in your init file:
(setq sgml-quick-keys 'close)
Out of the box, pressing C-c /
or C-c C-e
or C-c /
inserts a closing tag (the whole </foo>
).
You can find out about these keys by typing C-h m
while editing an HTML file. This displays the list of mode-specific key bindings. Look for something relevant there — the keys are bound to a command called sgml-close-tag
. The binding C-c /
is also mentioned in the manual.
Finding out about the </
behavior is harder: it's missing both from the manual and from the self-documentation. Pressing C-h k /
tells you that /
is bound to sgml-slash
, and that it “behaves electrically” (that's Emacs-speak for “it inserts some stuff automatically”) when sgml-quick-keys
is non-nil, but to find out about close
you need to look at the source code.
Note that there are other HTML modes for Emacs and they may do things completely differently.
C-c C-e
runs the commandsgml-close-tag
web-mode
should do