Inserting Page Breaks

Although Emacs doesn’t provide any pagination features, you can insert page breaks in your file. First, type the quote command (C-q), which tells Emacs to insert the following character into the text, whatever it is (rather than interpreting the character as a command). Then type C-l in the first column of the line. On your screen this character will look like ^L. Even though this character appears to be two characters, it’s really one; try erasing it and you’ll see what we mean.

C-l is a special character called a formfeed. Many printers (particularly line printers, daisywheel printers, and dot matrix printers) and some UNIX utilities (for example, more) interpret a formfeed as a page break. C-l is meaningless (or worse, may cause problems) to formatting programs like troff and TEX and to many laser printers (although many laser printers have a line printer emulation mode, which will probably interpret a formfeed correctly).

The only disadvantage to using this type of page break is that it’s a hard page break. If you edit your text and a page grows or shrinks, you’ll have to put in new page breaks to make the page look right when it prints. One approach is to never put page breaks in your working file. When you’re ready to print the file, copy it, then write a simple macro to insert page breaks every n lines, where n is the number of lines per page. For information on writing macros, see Chapter 10s.

Get Learning GNU Emacs, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.