Table 7-2lists the indentation commands we've discussed.
Table 7-2. Indentation commands
Keystrokes |
Command name |
Action |
C-j |
newline-and-indent |
Move to the next line and indent to the current level. |
( none ) |
paragraph-indent-text-mode |
A major mode for writing paragraphs with indented first lines and no blank lines between paragraphs. |
( none ) |
paragraph-indent-minor-mode |
The minor mode equivalent of paragraph-indent-text mode. |
( none ) |
fill-individual-paragraphs |
Reformat indented paragraphs, preserving indentation. |
C-x Tab |
indent-rigidly |
Indent one column; preface with C-uor M-nto specify multiple columns. |
C-M-\ |
indent-region |
Indent a region to match the first line in the region. |
M-m |
back-to-indentation |
Move the cursor to the first non-whitespace character on a line. |
C-M-o |
split-line |
Split the line at the cursor position and indent it to the column of the cursor position. |
( none ) Edit → Text Properties → Indentation → Indent More |
increase-left-margin |
Increase the left indentation level for the buffer by four characters by default. |
( none ) Edit → Text Properties → Indentation → Indent Less |
decrease-left-margin |
Decrease the left indentation level for the buffer by four characters by default. |
( none ) Edit → Text Properties → Indentation → Indent Right More |
decrease-right-margin |
Decrease the right indentation level for the buffer by four characters by default. |
( none ) Edit → Text Properties → Indentation → Indent Left More |
increase-right-margin |
Increase the right indentation level for the buffer by four characters by default. |
C-x . |
set-fill-prefix |
Use the information up to the cursor column as a prefix to each line of the paragraph; typing this command in column 1 cancels the fill prefix. |
Another common formatting task is centering text. For example, you might want to center the title of a document or individual headings within a document. Emacs provides commands to center lines, paragraphs, and regions.
In text mode, you can center a line by simply typing the line you want to center (or moving anywhere on an existing line), and then pressing M-s.
Type: Annual Report

You type the document's title.
Type: M-s

Emacs centers the line.
You can also center paragraphs and regions. In both cases, Emacs does line-by-line centering rather than block centering. To center a paragraph, use the command M-S(for center-paragraph); to center a region, use M-x center-region. For example, let's say you want to center the following quotation.
Type: M-S

Text is now centered.
In this case, line-by-line centering looks rather artistic. But there are times when you might wish Emacs did block centering. You can replicate this effect by using the indent-rigidlycommand, discussed earlier in this chapter. You just have to play with the indentation to see how far the block of text should be indented to look centered.
There's one more choice for centering. You can change justification by choosing Edit → Text Properties → Justification → Center. This command works on whatever text is selected.
Table 7-3lists the commands used to center text.
Table 7-3. Centering commands
Keystrokes |
Command name |
Action |
M-s |
center-line |
Center the line the cursor is on. |
M-S |
center-paragraph |
Center the paragraph the cursor is on. |
( none ) |
center-region |
Center the currently defined region. |
( none ) Edit → Text Properties → Justification → Center |
set-justification-center |
Center selected text. |
When you're writing something, whether it's a book, a long paper, or a technical specification, getting a sense of organization as you go along is frequently difficult. Without a sense of structure, it is hard to expand an outline smoothly into a longer paper or to reorganize a paper as you go along. The words get in the way of your headings, making it hard to see the forest for the trees.
Outline mode provides a built-in solution to this problem. This mode gives you the ability to hide or display text selectively, based on its relationship to the structure of your document. For example, you can hide all of your document's text except for its headings, thereby giving you a feel for the document's shape. When you're looking at the headings, you can focus on structure without being concerned about individual paragraphs. When you've solved your structural problems, you can make the text reappear.
Outline mode is more useful for documents with several levels of headings (or for long programs) than for plain outlines containing very little text. The longer a document is, the harder it is to get a quick feel for the overall structure; it is in such a situation that outline mode's ability to hide and show portions of the text comes in handy.
Outline mode requires you to follow some special conventions in your outline or document. Figure 7-1shows an outline in traditional format and the same outline prepared for outline mode. On the left, we show a "traditional" outline; on the right, we show the same outline, after being prepared for outline mode:
Figure 7-1. Traditional Outline versus Outline Mode
Whereas traditional outlines use a hierarchical scheme of Roman numerals, uppercase letters, numbers, and lowercase letters for heading levels 1 through 4, outline mode by default expects to see one asterisk (*) for a first-level heading, two for a second-level heading, and so on. Lines that don't start with an *, such as "This book is all-inclusive," are referred to as body lines. Notice that Emacs expects to see the asterisk in the first column. You can use traditional outline indentation, provided that the asterisks start in the first column. [37]
The sample outline has only two body lines. As we developed the book, though, we'd gradually add more and more body: "This book is all-inclusive" would be replaced by a substantial chunk of the preface, and other body lines later in the outline would turn into the text for Chapter 1 Chapter 1. Emacs Basics Some of you out there are probably dying to get your hands on the keyboard and start typing. We won't try to stop you; turn to the section called "Starting Emacs" and you can go ahead. But do read the beginning of this chapter later when you're ready for a break. Emacs is much easier to learn if you understand some of the basic concepts involved, which we discuss in the following introduction.
. When used properly, outline mode removes the distinction between outlining and writing. As your outline grows and becomes more detailed, it can gradually become your paper.
Читать дальше