: Learning GNU Emacs, 3rd Edition

8.3.2.4 Putting tags around a region

8.3.2.4 Putting tags around a region

When editing HTML files, you often spend a lot of time marking up existing text. If you preface any of the tag commands with C-u, Emacs inserts the tags around a region rather than putting them at the cursor position.[48] To demonstrate, we'll start a new HTML file and insert text from our dickens file.

Type: C-x C-f ataleoftwocities.html


Emacs inserts the HTML template.

Move the cursor past the <h1> pair and type C-x C-i dickens.


Emacs inserts the dickens text file, to which we can add HTML tags.

If you were really doing this properly, you'd type something like "A Tale of Two Cities, Chapter 1 as the title and the first-level header. But for now, you just want to see how to mark up a region of existing text. Begin by marking the Dickens paragraph as a region and type C-u M-Enter.

Type: M-h C-u M-Enter.


Emacs inserts opening and closing paragraph tags.


: 0.346. /Cache: 3 / 1