Next: , Previous: Paragraphs, Up: Text


30.4 Pages

Files are often thought of as divided into pages by the formfeed character (ASCII control-L, octal code 014). When you print hardcopy for a file, this character forces a page break; thus, each page of the file goes on a separate page on paper. Most Emacs commands treat the page-separator character just like any other character: you can insert it with C-q C-l, and delete it with <DEL>. Thus, you are free to paginate your file or not. However, since pages are often meaningful divisions of the file, Emacs provides commands to move over them and operate on them.

C-x [
Move point to previous page boundary (backward-page).
C-x ]
Move point to next page boundary (forward-page).
C-x C-p
Put point and mark around this page (or another page) (mark-page).
C-x l
Count the lines in this page (count-lines-page).

The C-x [ (backward-page) command moves point to immediately after the previous page delimiter. If point is already right after a page delimiter, it skips that one and stops at the previous one. A numeric argument serves as a repeat count. The C-x ] (forward-page) command moves forward past the next page delimiter.

The C-x C-p command (mark-page) puts point at the beginning of the current page and the mark at the end. The page delimiter at the end is included (the mark follows it). The page delimiter at the front is excluded (point follows it). In Transient Mark mode, this command activates the mark.

C-x C-p C-w is a handy way to kill a page to move it elsewhere. If you move to another page delimiter with C-x [ and C-x ], then yank the killed page, all the pages will be properly delimited once again. The reason C-x C-p includes only the following page delimiter in the region is to ensure that.

A numeric argument to C-x C-p is used to specify which page to go to, relative to the current one. Zero means the current page. One means the next page, and −1 means the previous one.

The C-x l command (count-lines-page) is good for deciding where to break a page in two. It displays in the echo area the total number of lines in the current page, and then divides it up into those preceding the current line and those following, as in

     Page has 96 (72+25) lines

Notice that the sum is off by one; this is correct if point is not at the beginning of a line.

The variable page-delimiter controls where pages begin. Its value is a regexp that matches the beginning of a line that separates pages. The normal value of this variable is "^\f", which matches a formfeed character at the beginning of a line.