Reputation: 1645
I need to insert <code> ...</code>
around a bunch of different words in multiple HTML documents. For example, if I have text like:
The clear command clears the current register
Then I would like to be be able to position the mark just before the first "clear", execute a quick keystroke like say C-c c , and have the text changed to
The <code>clear</code> command clears the current register
I have to do this a lot.
I'm using html-mode in emacs 25.
Note: I also wouldn't mind a command for wrapping <code>...</code>
around the current region.
Upvotes: 2
Views: 711
Reputation: 28104
By default, at least as of Emacs 27.1, if you open an html file, you have the sgml-mode commands available to you. This includes the command sgml-tag
which is bound to C-c C-o
.
If you select a region, then do C-c C-o
, if will prompt you to type the name of the tag and then for attributes. So if you entered "code" for the tag and then hit enter for no attributes, that would do what you wanted.
Upvotes: 0
Reputation: 1716
wrap-region-mode will do what you want. You can install it with package manager.
Wrap Region is a minor mode for Emacs that wraps a region with punctuations. For "tagged" markup modes, such as HTML and XML, it wraps with tags.
It has default "wrappers" defined but you can add wrappers like your <code>
tag.
Upvotes: 2