]> code.delx.au - gnu-emacs/blob - doc/emacs/text.texi
Change all occurrences of "Mouse-[0-9]" to "mouse-[0-9]"
[gnu-emacs] / doc / emacs / text.texi
1 @c -*- coding: utf-8 -*-
2 @c This is part of the Emacs manual.
3 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2016 Free Software
4 @c Foundation, Inc.
5 @c See file emacs.texi for copying conditions.
6 @node Text
7 @chapter Commands for Human Languages
8 @cindex text
9 @cindex manipulating text
10
11 This chapter describes Emacs commands that act on @dfn{text}, by
12 which we mean sequences of characters in a human language (as opposed
13 to, say, a computer programming language). These commands act in ways
14 that take into account the syntactic and stylistic conventions of
15 human languages: conventions involving words, sentences, paragraphs,
16 and capital letters. There are also commands for @dfn{filling}, which
17 means rearranging the lines of a paragraph to be approximately equal
18 in length. These commands, while intended primarily for editing text,
19 are also often useful for editing programs.
20
21 Emacs has several major modes for editing human-language text. If
22 the file contains ordinary text, use Text mode, which customizes Emacs
23 in small ways for the syntactic conventions of text. Outline mode
24 provides special commands for operating on text with an outline
25 structure. Org mode extends Outline mode and turn Emacs into a
26 full-fledged organizer: you can manage TODO lists, store notes and
27 publish them in many formats.
28
29 @iftex
30 @xref{Outline Mode}.
31 @end iftex
32
33 @cindex nXML mode
34 @cindex mode, XML
35 @cindex mode, nXML
36 @findex nxml-mode
37 Emacs has other major modes for text which contains embedded
38 commands, such as @TeX{} and @LaTeX{} (@pxref{TeX Mode}); HTML and
39 SGML (@pxref{HTML Mode}); XML
40 @ifinfo
41 (@pxref{Top,The nXML Mode Manual,,nxml-mode, nXML Mode});
42 @end ifinfo
43 @ifnotinfo
44 (see the nXML mode Info manual, which is distributed with Emacs);
45 @end ifnotinfo
46 and Groff and Nroff (@pxref{Nroff Mode}).
47
48 @cindex ASCII art
49 If you need to edit ASCII art pictures made out of text characters,
50 use Picture mode, a special major mode for editing such pictures.
51 @iftex
52 @xref{Picture Mode,,, emacs-xtra, Specialized Emacs Features}.
53 @end iftex
54 @ifnottex
55 @xref{Picture Mode}.
56 @end ifnottex
57
58 @ifinfo
59 @cindex skeletons
60 @cindex templates
61 @cindex autotyping
62 @cindex automatic typing
63 The automatic typing features may be useful when writing text.
64 @inforef{Top,The Autotype Manual,autotype}.
65 @end ifinfo
66
67 @menu
68 * Words:: Moving over and killing words.
69 * Sentences:: Moving over and killing sentences.
70 * Paragraphs:: Moving over paragraphs.
71 * Pages:: Moving over pages.
72 * Quotation Marks:: Inserting quotation marks.
73 * Filling:: Filling or justifying text.
74 * Case:: Changing the case of text.
75 * Text Mode:: The major modes for editing text files.
76 * Outline Mode:: Editing outlines.
77 * Org Mode:: The Emacs organizer.
78 * TeX Mode:: Editing TeX and LaTeX files.
79 * HTML Mode:: Editing HTML and SGML files.
80 * Nroff Mode:: Editing input to the nroff formatter.
81 * Enriched Text:: Editing text enriched with fonts, colors, etc.
82 * Text Based Tables:: Commands for editing text-based tables.
83 * Two-Column:: Splitting text columns into separate windows.
84 @end menu
85
86 @node Words
87 @section Words
88 @cindex words
89 @cindex Meta commands and words
90
91 Emacs defines several commands for moving over or operating on
92 words:
93
94 @table @kbd
95 @item M-f
96 Move forward over a word (@code{forward-word}).
97 @item M-b
98 Move backward over a word (@code{backward-word}).
99 @item M-d
100 Kill up to the end of a word (@code{kill-word}).
101 @item M-@key{DEL}
102 Kill back to the beginning of a word (@code{backward-kill-word}).
103 @item M-@@
104 Mark the end of the next word (@code{mark-word}).
105 @item M-t
106 Transpose two words or drag a word across others
107 (@code{transpose-words}).
108 @end table
109
110 Notice how these keys form a series that parallels the character-based
111 @kbd{C-f}, @kbd{C-b}, @kbd{C-d}, @key{DEL} and @kbd{C-t}. @kbd{M-@@} is
112 cognate to @kbd{C-@@}, which is an alias for @kbd{C-@key{SPC}}.
113
114 @kindex M-f
115 @kindex M-b
116 @findex forward-word
117 @findex backward-word
118 The commands @kbd{M-f} (@code{forward-word}) and @kbd{M-b}
119 (@code{backward-word}) move forward and backward over words. These
120 @key{META}-based key sequences are analogous to the key sequences
121 @kbd{C-f} and @kbd{C-b}, which move over single characters. The
122 analogy extends to numeric arguments, which serve as repeat counts.
123 @kbd{M-f} with a negative argument moves backward, and @kbd{M-b} with
124 a negative argument moves forward. Forward motion stops right after
125 the last letter of the word, while backward motion stops right before
126 the first letter.
127
128 @kindex M-d
129 @findex kill-word
130 @kbd{M-d} (@code{kill-word}) kills the word after point. To be
131 precise, it kills everything from point to the place @kbd{M-f} would
132 move to. Thus, if point is in the middle of a word, @kbd{M-d} kills
133 just the part after point. If some punctuation comes between point
134 and the next word, it is killed along with the word. (If you wish to
135 kill only the next word but not the punctuation before it, simply do
136 @kbd{M-f} to get the end, and kill the word backwards with
137 @kbd{M-@key{DEL}}.) @kbd{M-d} takes arguments just like @kbd{M-f}.
138
139 @findex backward-kill-word
140 @kindex M-DEL
141 @kbd{M-@key{DEL}} (@code{backward-kill-word}) kills the word before
142 point. It kills everything from point back to where @kbd{M-b} would
143 move to. For instance, if point is after the space in @w{@samp{FOO,
144 BAR}}, it kills @w{@samp{FOO, }}. If you wish to kill just
145 @samp{FOO}, and not the comma and the space, use @kbd{M-b M-d} instead
146 of @kbd{M-@key{DEL}}.
147
148 @c Don't index M-t and transpose-words here, they are indexed in
149 @c fixit.texi, in the node "Transpose".
150 @c @kindex M-t
151 @c @findex transpose-words
152 @kbd{M-t} (@code{transpose-words}) exchanges the word before or
153 containing point with the following word. The delimiter characters between
154 the words do not move. For example, @w{@samp{FOO, BAR}} transposes into
155 @w{@samp{BAR, FOO}} rather than @samp{@w{BAR FOO,}}. @xref{Transpose}, for
156 more on transposition.
157
158 @kindex M-@@
159 @findex mark-word
160 To operate on words with an operation which acts on the region, use
161 the command @kbd{M-@@} (@code{mark-word}). This command sets the mark
162 where @kbd{M-f} would move to. @xref{Marking Objects}, for more
163 information about this command.
164
165 The word commands' understanding of word boundaries is controlled by
166 the syntax table. Any character can, for example, be declared to be a
167 word delimiter. @xref{Syntax Tables,, Syntax Tables, elisp, The Emacs
168 Lisp Reference Manual}.
169
170 In addition, see @ref{Position Info} for the @kbd{M-=}
171 (@code{count-words-region}) and @kbd{M-x count-words} commands, which
172 count and report the number of words in the region or buffer.
173
174 @node Sentences
175 @section Sentences
176 @cindex sentences
177 @cindex manipulating sentences
178
179 The Emacs commands for manipulating sentences and paragraphs are
180 mostly on Meta keys, like the word-handling commands.
181
182 @table @kbd
183 @item M-a
184 Move back to the beginning of the sentence (@code{backward-sentence}).
185 @item M-e
186 Move forward to the end of the sentence (@code{forward-sentence}).
187 @item M-k
188 Kill forward to the end of the sentence (@code{kill-sentence}).
189 @item C-x @key{DEL}
190 Kill back to the beginning of the sentence (@code{backward-kill-sentence}).
191 @end table
192
193 @kindex M-a
194 @kindex M-e
195 @findex backward-sentence
196 @findex forward-sentence
197 The commands @kbd{M-a} (@code{backward-sentence}) and @kbd{M-e}
198 (@code{forward-sentence}) move to the beginning and end of the current
199 sentence, respectively. Their bindings were chosen to resemble
200 @kbd{C-a} and @kbd{C-e}, which move to the beginning and end of a
201 line. Unlike them, @kbd{M-a} and @kbd{M-e} move over successive
202 sentences if repeated.
203
204 Moving backward over a sentence places point just before the first
205 character of the sentence; moving forward places point right after the
206 punctuation that ends the sentence. Neither one moves over the
207 whitespace at the sentence boundary.
208
209 @kindex M-k
210 @findex kill-sentence
211 Just as @kbd{C-a} and @kbd{C-e} have a kill command, @kbd{C-k}, to
212 go with them, @kbd{M-a} and @kbd{M-e} have a corresponding kill
213 command: @kbd{M-k} (@code{kill-sentence}) kills from point to the end
214 of the sentence. With a positive numeric argument @var{n}, it kills
215 the next @var{n} sentences; with a negative argument @minus{}@var{n},
216 it kills back to the beginning of the @var{n}th preceding sentence.
217
218 @kindex C-x DEL
219 @findex backward-kill-sentence
220 The @kbd{C-x @key{DEL}} (@code{backward-kill-sentence}) kills back
221 to the beginning of a sentence.
222
223 The sentence commands assume that you follow the American typist's
224 convention of putting two spaces at the end of a sentence. That is, a
225 sentence ends wherever there is a @samp{.}, @samp{?} or @samp{!}
226 followed by the end of a line or two spaces, with any number of
227 @samp{)}, @samp{]}, @samp{'}, or @samp{"} characters allowed in
228 between. A sentence also begins or ends wherever a paragraph begins
229 or ends. It is useful to follow this convention, because it allows
230 the Emacs sentence commands to distinguish between periods that end a
231 sentence and periods that indicate abbreviations.
232
233 @vindex sentence-end-double-space
234 If you want to use just one space between sentences, you can set the
235 variable @code{sentence-end-double-space} to @code{nil} to make the
236 sentence commands stop for single spaces. However, this has a
237 drawback: there is no way to distinguish between periods that end
238 sentences and those that indicate abbreviations. For convenient and
239 reliable editing, we therefore recommend you follow the two-space
240 convention. The variable @code{sentence-end-double-space} also
241 affects filling (@pxref{Fill Commands}).
242
243 @vindex sentence-end
244 The variable @code{sentence-end} controls how to recognize the end
245 of a sentence. If non-@code{nil}, its value should be a regular
246 expression, which is used to match the last few characters of a
247 sentence, together with the whitespace following the sentence
248 (@pxref{Regexps}). If the value is @code{nil}, the default, then
249 Emacs computes sentence ends according to various criteria such as the
250 value of @code{sentence-end-double-space}.
251
252 @vindex sentence-end-without-period
253 Some languages, such as Thai, do not use periods to indicate the end
254 of a sentence. Set the variable @code{sentence-end-without-period} to
255 @code{t} in such cases.
256
257 @node Paragraphs
258 @section Paragraphs
259 @cindex paragraphs
260 @cindex manipulating paragraphs
261
262 The Emacs commands for manipulating paragraphs are also on Meta keys.
263
264 @table @kbd
265 @item M-@{
266 Move back to previous paragraph beginning (@code{backward-paragraph}).
267 @item M-@}
268 Move forward to next paragraph end (@code{forward-paragraph}).
269 @item M-h
270 Put point and mark around this or next paragraph (@code{mark-paragraph}).
271 @end table
272
273 @kindex M-@{
274 @kindex M-@}
275 @findex backward-paragraph
276 @findex forward-paragraph
277 @kbd{M-@{} (@code{backward-paragraph}) moves to the beginning of the
278 current or previous paragraph (see below for the definition of a
279 paragraph). @kbd{M-@}} (@code{forward-paragraph}) moves to the end of
280 the current or next paragraph. If there is a blank line before the
281 paragraph, @kbd{M-@{} moves to the blank line.
282
283 @kindex M-h
284 @findex mark-paragraph
285 When you wish to operate on a paragraph, type @kbd{M-h}
286 (@code{mark-paragraph}) to set the region around it. For example,
287 @kbd{M-h C-w} kills the paragraph around or after point. @kbd{M-h}
288 puts point at the beginning and mark at the end of the paragraph point
289 was in. If point is between paragraphs (in a run of blank lines, or
290 at a boundary), @kbd{M-h} sets the region around the paragraph
291 following point. If there are blank lines preceding the first line of
292 the paragraph, one of these blank lines is included in the region. If
293 the region is already active, the command sets the mark without
294 changing point, and each subsequent @kbd{M-h} further advances the
295 mark by one paragraph.
296
297 The definition of a paragraph depends on the major mode. In
298 Fundamental mode, as well as Text mode and related modes, a paragraph
299 is separated each neighboring paragraph another by one or more
300 @dfn{blank lines}---lines that are either empty, or consist solely of
301 space, tab and/or formfeed characters. In programming language modes,
302 paragraphs are usually defined in a similar way, so that you can use
303 the paragraph commands even though there are no paragraphs as such in
304 a program.
305
306 Note that an indented line is @emph{not} itself a paragraph break in
307 Text mode. If you want indented lines to separate paragraphs, use
308 Paragraph-Indent Text mode instead. @xref{Text Mode}.
309
310 If you set a fill prefix, then paragraphs are delimited by all lines
311 which don't start with the fill prefix. @xref{Filling}.
312
313 @vindex paragraph-start
314 @vindex paragraph-separate
315 The precise definition of a paragraph boundary is controlled by the
316 variables @code{paragraph-separate} and @code{paragraph-start}. The
317 value of @code{paragraph-start} is a regular expression that should
318 match lines that either start or separate paragraphs
319 (@pxref{Regexps}). The value of @code{paragraph-separate} is another
320 regular expression that should match lines that separate paragraphs
321 without being part of any paragraph (for example, blank lines). Lines
322 that start a new paragraph and are contained in it must match only
323 @code{paragraph-start}, not @code{paragraph-separate}. For example,
324 in Fundamental mode, @code{paragraph-start} is @w{@code{"\f\\|[
325 \t]*$"}}, and @code{paragraph-separate} is @w{@code{"[ \t\f]*$"}}.
326
327 @node Pages
328 @section Pages
329
330 @cindex pages
331 @cindex formfeed character
332 Within some text files, text is divided into @dfn{pages} delimited
333 by the @dfn{formfeed character} (@acronym{ASCII} code 12, also denoted
334 as @samp{control-L}), which is displayed in Emacs as the escape
335 sequence @samp{^L} (@pxref{Text Display}). Traditionally, when such
336 text files are printed to hardcopy, each formfeed character forces a
337 page break. Most Emacs commands treat it just like any other
338 character, so you can insert it with @kbd{C-q C-l}, delete it with
339 @key{DEL}, etc. In addition, Emacs provides commands to move over
340 pages and operate on them.
341
342 @table @kbd
343 @item M-x what-page
344 Display the page number of point, and the line number within that page.
345 @item C-x [
346 Move point to previous page boundary (@code{backward-page}).
347 @item C-x ]
348 Move point to next page boundary (@code{forward-page}).
349 @item C-x C-p
350 Put point and mark around this page (or another page) (@code{mark-page}).
351 @item C-x l
352 Count the lines in this page (@code{count-lines-page}).
353 @end table
354
355 @findex what-page
356 @kbd{M-x what-page} counts pages from the beginning of the file, and
357 counts lines within the page, showing both numbers in the echo area.
358
359 @kindex C-x [
360 @kindex C-x ]
361 @findex forward-page
362 @findex backward-page
363 The @kbd{C-x [} (@code{backward-page}) command moves point to immediately
364 after the previous page delimiter. If point is already right after a page
365 delimiter, it skips that one and stops at the previous one. A numeric
366 argument serves as a repeat count. The @kbd{C-x ]} (@code{forward-page})
367 command moves forward past the next page delimiter.
368
369 @kindex C-x C-p
370 @findex mark-page
371 The @kbd{C-x C-p} command (@code{mark-page}) puts point at the
372 beginning of the current page (after that page delimiter at the
373 front), and the mark at the end of the page (after the page delimiter
374 at the end).
375
376 @kbd{C-x C-p C-w} is a handy way to kill a page to move it
377 elsewhere. If you move to another page delimiter with @kbd{C-x [} and
378 @kbd{C-x ]}, then yank the killed page, all the pages will be properly
379 delimited once again. The reason @kbd{C-x C-p} includes only the
380 following page delimiter in the region is to ensure that.
381
382 A numeric argument to @kbd{C-x C-p} specifies which page to go to,
383 relative to the current one. Zero means the current page, one
384 the next page, and @minus{}1 the previous one.
385
386 @kindex C-x l
387 @findex count-lines-page
388 The @kbd{C-x l} command (@code{count-lines-page}) is good for deciding
389 where to break a page in two. It displays in the echo area the total number
390 of lines in the current page, and then divides it up into those preceding
391 the current line and those following, as in
392
393 @example
394 Page has 96 (72+25) lines
395 @end example
396
397 @noindent
398 Notice that the sum is off by one; this is correct if point is not at the
399 beginning of a line.
400
401 @vindex page-delimiter
402 The variable @code{page-delimiter} controls where pages begin. Its
403 value is a regular expression that matches the beginning of a line
404 that separates pages (@pxref{Regexps}). The normal value of this
405 variable is @code{"^\f"}, which matches a formfeed character at the
406 beginning of a line.
407
408 @node Quotation Marks
409 @section Quotation Marks
410 @cindex Quotation marks
411 @cindex Electric Quote mode
412 @cindex mode, Electric Quote
413 @cindex curly quotes
414 @cindex curved quotes
415 @findex electric-quote-mode
416 One common way to quote is the typewriter convention, which quotes
417 using straight apostrophes @t{'like this'} or double-quotes @t{"like
418 this"}. Another common way is the curved quote convention, which uses
419 left and right single or double quotation marks @t{‘like this’} or
420 @t{“like this”}. In text files, typewriter quotes are simple and
421 portable; curved quotes are less ambiguous and typically look nicer.
422
423 Electric Quote mode makes it easier to type curved quotes. As you
424 type characters it optionally converts @t{`} to @t{‘}, @t{'} to @t{’},
425 @t{``} to @t{“}, and @t{''} to @t{”}. These conversions are
426 suppressed in buffers whose coding systems cannot represent curved
427 quote characters.
428
429 @vindex electric-quote-paragraph
430 @vindex electric-quote-comment
431 @vindex electric-quote-string
432 You can customize the behavior of Electric Quote mode by customizing
433 variables that control where it is active. It is active in text
434 paragraphs if @code{electric-quote-paragraph} is non-@code{nil}, in
435 programming-language comments if @code{electric-quote-comment} is
436 non-@code{nil}, and in programming-language strings if
437 @code{electric-quote-string} is non-@code{nil}. The default is
438 @code{nil} for @code{electric-quote-string} and @code{t} for the other
439 variables.
440
441 Electric Quote mode is disabled by default. To toggle it, type
442 @kbd{M-x electric-quote-mode}. To toggle it in a single buffer, use
443 @kbd{M-x electric-quote-local-mode}. To suppress it for a single use,
444 type @kbd{C-q `} or @kbd{C-q '} instead of @kbd{`} or @kbd{'}. To
445 insert a curved quote even when Electric Quote is disabled or
446 inactive, you can type @kbd{C-x 8 [} for @t{‘}, @kbd{C-x 8 ]} for
447 @t{’}, @kbd{C-x 8 @{} for @t{“}, and @kbd{C-x 8 @}} for @t{”}.
448 @xref{Inserting Text}.
449
450 @node Filling
451 @section Filling Text
452 @cindex filling text
453
454 @dfn{Filling} text means breaking it up into lines that fit a
455 specified width. Emacs does filling in two ways. In Auto Fill mode,
456 inserting text with self-inserting characters also automatically fills
457 it. There are also explicit fill commands that you can use when editing
458 text.
459
460 @menu
461 * Auto Fill:: Auto Fill mode breaks long lines automatically.
462 * Fill Commands:: Commands to refill paragraphs and center lines.
463 * Fill Prefix:: Filling paragraphs that are indented or in a comment, etc.
464 * Adaptive Fill:: How Emacs can determine the fill prefix automatically.
465 @end menu
466
467 @node Auto Fill
468 @subsection Auto Fill Mode
469 @cindex Auto Fill mode
470 @cindex mode, Auto Fill
471
472 @dfn{Auto Fill} mode is a buffer-local minor mode (@pxref{Minor
473 Modes}) in which lines are broken automatically when they become too
474 wide. Breaking happens only when you type a @key{SPC} or @key{RET}.
475
476 @table @kbd
477 @item M-x auto-fill-mode
478 Enable or disable Auto Fill mode.
479 @item @key{SPC}
480 @itemx @key{RET}
481 In Auto Fill mode, break lines when appropriate.
482 @end table
483
484 @findex auto-fill-mode
485 The mode command @kbd{M-x auto-fill-mode} toggles Auto Fill mode in
486 the current buffer. With a positive numeric argument, it enables Auto
487 Fill mode, and with a negative argument it disables it. If
488 @code{auto-fill-mode} is called from Lisp with an omitted or
489 @code{nil} argument, it enables Auto Fill mode. To enable Auto Fill
490 mode automatically in certain major modes, add @code{auto-fill-mode}
491 to the mode hooks (@pxref{Major Modes}). When Auto Fill mode is
492 enabled, the mode indicator @samp{Fill} appears in the mode line
493 (@pxref{Mode Line}).
494
495 Auto Fill mode breaks lines automatically at spaces whenever they
496 get longer than the desired width. This line breaking occurs only
497 when you type @key{SPC} or @key{RET}. If you wish to insert a space
498 or newline without permitting line-breaking, type @kbd{C-q @key{SPC}}
499 or @kbd{C-q C-j} respectively. Also, @kbd{C-o} inserts a newline
500 without line breaking.
501
502 When Auto Fill mode breaks a line, it tries to obey the
503 @dfn{adaptive fill prefix}: if a fill prefix can be deduced from the
504 first and/or second line of the current paragraph, it is inserted into
505 the new line (@pxref{Adaptive Fill}). Otherwise the new line is
506 indented, as though you had typed @key{TAB} on it
507 (@pxref{Indentation}). In a programming language mode, if a line is
508 broken in the middle of a comment, the comment is split by inserting
509 new comment delimiters as appropriate.
510
511 Auto Fill mode does not refill entire paragraphs; it breaks lines
512 but does not merge lines. Therefore, editing in the middle of a
513 paragraph can result in a paragraph that is not correctly filled. To
514 fill it, call the explicit fill commands
515 @iftex
516 described in the next section.
517 @end iftex
518 @ifnottex
519 (@pxref{Fill Commands}).
520 @end ifnottex
521
522 @node Fill Commands
523 @subsection Explicit Fill Commands
524
525 @table @kbd
526 @item M-q
527 Fill current paragraph (@code{fill-paragraph}).
528 @item C-x f
529 Set the fill column (@code{set-fill-column}).
530 @item M-x fill-region
531 Fill each paragraph in the region (@code{fill-region}).
532 @item M-x fill-region-as-paragraph
533 Fill the region, considering it as one paragraph.
534 @item M-o M-s
535 Center a line.
536 @end table
537
538 @kindex M-q
539 @findex fill-paragraph
540 The command @kbd{M-q} (@code{fill-paragraph}) @dfn{fills} the
541 current paragraph. It redistributes the line breaks within the
542 paragraph, and deletes any excess space and tab characters occurring
543 within the paragraph, in such a way that the lines end up fitting
544 within a certain maximum width.
545
546 @findex fill-region
547 Normally, @kbd{M-q} acts on the paragraph where point is, but if
548 point is between paragraphs, it acts on the paragraph after point. If
549 the region is active, it acts instead on the text in the region. You
550 can also call @kbd{M-x fill-region} to specifically fill the text in
551 the region.
552
553 @findex fill-region-as-paragraph
554 @kbd{M-q} and @code{fill-region} use the usual Emacs criteria for
555 finding paragraph boundaries (@pxref{Paragraphs}). For more control,
556 you can use @kbd{M-x fill-region-as-paragraph}, which refills
557 everything between point and mark as a single paragraph. This command
558 deletes any blank lines within the region, so separate blocks of text
559 end up combined into one block.
560
561 @cindex justification
562 A numeric argument to @kbd{M-q} tells it to @dfn{justify} the text
563 as well as filling it. This means that extra spaces are inserted to
564 make the right margin line up exactly at the fill column. To remove
565 the extra spaces, use @kbd{M-q} with no argument. (Likewise for
566 @code{fill-region}.)
567
568 @vindex fill-column
569 @kindex C-x f
570 @findex set-fill-column
571 The maximum line width for filling is specified by the buffer-local
572 variable @code{fill-column}. The default value (@pxref{Locals}) is
573 70. The easiest way to set @code{fill-column} in the current buffer
574 is to use the command @kbd{C-x f} (@code{set-fill-column}). With a
575 numeric argument, it uses that as the new fill column. With just
576 @kbd{C-u} as argument, it sets @code{fill-column} to the current
577 horizontal position of point.
578
579 @kindex M-o M-s @r{(Text mode)}
580 @cindex centering
581 @findex center-line
582 The command @kbd{M-o M-s} (@code{center-line}) centers the current line
583 within the current fill column. With an argument @var{n}, it centers
584 @var{n} lines individually and moves past them. This binding is
585 made by Text mode and is available only in that and related modes
586 (@pxref{Text Mode}).
587
588 By default, Emacs considers a period followed by two spaces or by a
589 newline as the end of a sentence; a period followed by just one space
590 indicates an abbreviation, not the end of a sentence. Accordingly,
591 the fill commands will not break a line after a period followed by
592 just one space. If you set the variable
593 @code{sentence-end-double-space} to @code{nil}, the fill commands will
594 break a line after a period followed by one space, and put just one
595 space after each period. @xref{Sentences}, for other effects and
596 possible drawbacks of this.
597
598 @vindex colon-double-space
599 If the variable @code{colon-double-space} is non-@code{nil}, the
600 fill commands put two spaces after a colon.
601
602 @vindex fill-nobreak-predicate
603 To specify additional conditions where line-breaking is not allowed,
604 customize the abnormal hook variable @code{fill-nobreak-predicate}
605 (@pxref{Hooks}). Each function in this hook is called with no
606 arguments, with point positioned where Emacs is considering breaking a
607 line. If a function returns a non-@code{nil} value, Emacs will not
608 break the line there. Functions you can use there include:
609 @code{fill-single-word-nobreak-p} (don't break after the first word of
610 a sentence or before the last); @code{fill-single-char-nobreak-p}
611 (don't break after a one-letter word); and @code{fill-french-nobreak-p}
612 (don't break after @samp{(} or before @samp{)}, @samp{:} or @samp{?}).
613
614 @node Fill Prefix
615 @subsection The Fill Prefix
616
617 @cindex fill prefix
618 The @dfn{fill prefix} feature allows paragraphs to be filled so that
619 each line starts with a special string of characters (such as a
620 sequence of spaces, giving an indented paragraph). You can specify a
621 fill prefix explicitly; otherwise, Emacs tries to deduce one
622 automatically (@pxref{Adaptive Fill}).
623
624 @table @kbd
625 @item C-x .
626 Set the fill prefix (@code{set-fill-prefix}).
627 @item M-q
628 Fill a paragraph using current fill prefix (@code{fill-paragraph}).
629 @item M-x fill-individual-paragraphs
630 Fill the region, considering each change of indentation as starting a
631 new paragraph.
632 @item M-x fill-nonuniform-paragraphs
633 Fill the region, considering only paragraph-separator lines as starting
634 a new paragraph.
635 @end table
636
637 @kindex C-x .
638 @findex set-fill-prefix
639 To specify a fill prefix for the current buffer, move to a line that
640 starts with the desired prefix, put point at the end of the prefix,
641 and type @w{@kbd{C-x .}}@: (@code{set-fill-prefix}). (That's a period
642 after the @kbd{C-x}.) To turn off the fill prefix, specify an empty
643 prefix: type @w{@kbd{C-x .}}@: with point at the beginning of a line.
644
645 When a fill prefix is in effect, the fill commands remove the fill
646 prefix from each line of the paragraph before filling, and insert it
647 on each line after filling. (The beginning of the first line of the
648 paragraph is left unchanged, since often that is intentionally
649 different.) Auto Fill mode also inserts the fill prefix automatically
650 when it makes a new line (@pxref{Auto Fill}). The @kbd{C-o} command
651 inserts the fill prefix on new lines it creates, when you use it at
652 the beginning of a line (@pxref{Blank Lines}). Conversely, the
653 command @kbd{M-^} deletes the prefix (if it occurs) after the newline
654 that it deletes (@pxref{Indentation}).
655
656 For example, if @code{fill-column} is 40 and you set the fill prefix
657 to @samp{;; }, then @kbd{M-q} in the following text
658
659 @example
660 ;; This is an
661 ;; example of a paragraph
662 ;; inside a Lisp-style comment.
663 @end example
664
665 @noindent
666 produces this:
667
668 @example
669 ;; This is an example of a paragraph
670 ;; inside a Lisp-style comment.
671 @end example
672
673 Lines that do not start with the fill prefix are considered to start
674 paragraphs, both in @kbd{M-q} and the paragraph commands; this gives
675 good results for paragraphs with hanging indentation (every line
676 indented except the first one). Lines which are blank or indented once
677 the prefix is removed also separate or start paragraphs; this is what
678 you want if you are writing multi-paragraph comments with a comment
679 delimiter on each line.
680
681 @findex fill-individual-paragraphs
682 You can use @kbd{M-x fill-individual-paragraphs} to set the fill
683 prefix for each paragraph automatically. This command divides the
684 region into paragraphs, treating every change in the amount of
685 indentation as the start of a new paragraph, and fills each of these
686 paragraphs. Thus, all the lines in one paragraph have the same
687 amount of indentation. That indentation serves as the fill prefix for
688 that paragraph.
689
690 @findex fill-nonuniform-paragraphs
691 @kbd{M-x fill-nonuniform-paragraphs} is a similar command that divides
692 the region into paragraphs in a different way. It considers only
693 paragraph-separating lines (as defined by @code{paragraph-separate}) as
694 starting a new paragraph. Since this means that the lines of one
695 paragraph may have different amounts of indentation, the fill prefix
696 used is the smallest amount of indentation of any of the lines of the
697 paragraph. This gives good results with styles that indent a paragraph's
698 first line more or less that the rest of the paragraph.
699
700 @vindex fill-prefix
701 The fill prefix is stored in the variable @code{fill-prefix}. Its value
702 is a string, or @code{nil} when there is no fill prefix. This is a
703 per-buffer variable; altering the variable affects only the current buffer,
704 but there is a default value which you can change as well. @xref{Locals}.
705
706 The @code{indentation} text property provides another way to control
707 the amount of indentation paragraphs receive. @xref{Enriched
708 Indentation}.
709
710 @node Adaptive Fill
711 @subsection Adaptive Filling
712
713 @cindex adaptive filling
714 The fill commands can deduce the proper fill prefix for a paragraph
715 automatically in certain cases: either whitespace or certain punctuation
716 characters at the beginning of a line are propagated to all lines of the
717 paragraph.
718
719 If the paragraph has two or more lines, the fill prefix is taken from
720 the paragraph's second line, but only if it appears on the first line as
721 well.
722
723 If a paragraph has just one line, fill commands @emph{may} take a
724 prefix from that line. The decision is complicated because there are
725 three reasonable things to do in such a case:
726
727 @itemize @bullet
728 @item
729 Use the first line's prefix on all the lines of the paragraph.
730
731 @item
732 Indent subsequent lines with whitespace, so that they line up under the
733 text that follows the prefix on the first line, but don't actually copy
734 the prefix from the first line.
735
736 @item
737 Don't do anything special with the second and following lines.
738 @end itemize
739
740 All three of these styles of formatting are commonly used. So the
741 fill commands try to determine what you would like, based on the prefix
742 that appears and on the major mode. Here is how.
743
744 @vindex adaptive-fill-first-line-regexp
745 If the prefix found on the first line matches
746 @code{adaptive-fill-first-line-regexp}, or if it appears to be a
747 comment-starting sequence (this depends on the major mode), then the
748 prefix found is used for filling the paragraph, provided it would not
749 act as a paragraph starter on subsequent lines.
750
751 Otherwise, the prefix found is converted to an equivalent number of
752 spaces, and those spaces are used as the fill prefix for the rest of the
753 lines, provided they would not act as a paragraph starter on subsequent
754 lines.
755
756 In Text mode, and other modes where only blank lines and page
757 delimiters separate paragraphs, the prefix chosen by adaptive filling
758 never acts as a paragraph starter, so it can always be used for filling.
759
760 @vindex adaptive-fill-mode
761 @vindex adaptive-fill-regexp
762 The variable @code{adaptive-fill-regexp} determines what kinds of line
763 beginnings can serve as a fill prefix: any characters at the start of
764 the line that match this regular expression are used. If you set the
765 variable @code{adaptive-fill-mode} to @code{nil}, the fill prefix is
766 never chosen automatically.
767
768 @vindex adaptive-fill-function
769 You can specify more complex ways of choosing a fill prefix
770 automatically by setting the variable @code{adaptive-fill-function} to a
771 function. This function is called with point after the left margin of a
772 line, and it should return the appropriate fill prefix based on that
773 line. If it returns @code{nil}, @code{adaptive-fill-regexp} gets
774 a chance to find a prefix.
775
776 @node Case
777 @section Case Conversion Commands
778 @cindex case conversion
779
780 Emacs has commands for converting either a single word or any arbitrary
781 range of text to upper case or to lower case.
782
783 @table @kbd
784 @item M-l
785 Convert following word to lower case (@code{downcase-word}).
786 @item M-u
787 Convert following word to upper case (@code{upcase-word}).
788 @item M-c
789 Capitalize the following word (@code{capitalize-word}).
790 @item C-x C-l
791 Convert region to lower case (@code{downcase-region}).
792 @item C-x C-u
793 Convert region to upper case (@code{upcase-region}).
794 @end table
795
796 @kindex M-l
797 @kindex M-u
798 @kindex M-c
799 @cindex words, case conversion
800 @cindex converting text to upper or lower case
801 @cindex capitalizing words
802 @findex downcase-word
803 @findex upcase-word
804 @findex capitalize-word
805 @kbd{M-l} (@code{downcase-word}) converts the word after point to
806 lower case, moving past it. Thus, repeating @kbd{M-l} converts
807 successive words. @kbd{M-u} (@code{upcase-word}) converts to all
808 capitals instead, while @kbd{M-c} (@code{capitalize-word}) puts the
809 first letter of the word into upper case and the rest into lower case.
810 All these commands convert several words at once if given an argument.
811 They are especially convenient for converting a large amount of text
812 from all upper case to mixed case, because you can move through the
813 text using @kbd{M-l}, @kbd{M-u} or @kbd{M-c} on each word as
814 appropriate, occasionally using @kbd{M-f} instead to skip a word.
815
816 When given a negative argument, the word case conversion commands apply
817 to the appropriate number of words before point, but do not move point.
818 This is convenient when you have just typed a word in the wrong case: you
819 can give the case conversion command and continue typing.
820
821 If a word case conversion command is given in the middle of a word,
822 it applies only to the part of the word which follows point. (This is
823 comparable to what @kbd{M-d} (@code{kill-word}) does.) With a
824 negative argument, case conversion applies only to the part of the
825 word before point.
826
827 @kindex C-x C-l
828 @kindex C-x C-u
829 @findex downcase-region
830 @findex upcase-region
831 The other case conversion commands are @kbd{C-x C-u}
832 (@code{upcase-region}) and @kbd{C-x C-l} (@code{downcase-region}), which
833 convert everything between point and mark to the specified case. Point and
834 mark do not move.
835
836 The region case conversion commands @code{upcase-region} and
837 @code{downcase-region} are normally disabled. This means that they ask
838 for confirmation if you try to use them. When you confirm, you may
839 enable the command, which means it will not ask for confirmation again.
840 @xref{Disabling}.
841
842 @node Text Mode
843 @section Text Mode
844 @cindex Text mode
845 @cindex mode, Text
846 @findex text-mode
847
848 Text mode is a major mode for editing files of text in a human
849 language. Files which have names ending in the extension @file{.txt}
850 are usually opened in Text mode (@pxref{Choosing Modes}). To
851 explicitly switch to Text mode, type @kbd{M-x text-mode}.
852
853 In Text mode, only blank lines and page delimiters separate
854 paragraphs. As a result, paragraphs can be indented, and adaptive
855 filling determines what indentation to use when filling a paragraph.
856 @xref{Adaptive Fill}.
857
858 @kindex TAB @r{(Text mode)}
859 In Text mode, the @key{TAB} (@code{indent-for-tab-command}) command
860 usually inserts whitespace up to the next tab stop, instead of
861 indenting the current line. @xref{Indentation}, for details.
862
863 Text mode turns off the features concerned with comments except when
864 you explicitly invoke them. It changes the syntax table so that
865 single-quotes are considered part of words (e.g., @samp{don't} is
866 considered one word). However, if a word starts with a single-quote,
867 it is treated as a prefix for the purposes of capitalization
868 (e.g., @kbd{M-c} converts @samp{'hello'} into @samp{'Hello'}, as
869 expected).
870
871 @cindex Paragraph-Indent Text mode
872 @cindex mode, Paragraph-Indent Text
873 @findex paragraph-indent-text-mode
874 @findex paragraph-indent-minor-mode
875 If you indent the first lines of paragraphs, then you should use
876 Paragraph-Indent Text mode (@kbd{M-x paragraph-indent-text-mode})
877 rather than Text mode. In that mode, you do not need to have blank
878 lines between paragraphs, because the first-line indentation is
879 sufficient to start a paragraph; however paragraphs in which every
880 line is indented are not supported. Use @kbd{M-x
881 paragraph-indent-minor-mode} to enable an equivalent minor mode for
882 situations where you shouldn't change the major mode---in mail
883 composition, for instance.
884
885 @kindex M-TAB @r{(Text mode)}
886 Text mode binds @kbd{M-@key{TAB}} to @code{ispell-complete-word}.
887 This command performs completion of the partial word in the buffer
888 before point, using the spelling dictionary as the space of possible
889 words. @xref{Spelling}. If your window manager defines
890 @kbd{M-@key{TAB}} to switch windows, you can type @kbd{@key{ESC}
891 @key{TAB}} or @kbd{C-M-i} instead.
892
893 @vindex text-mode-hook
894 Entering Text mode runs the mode hook @code{text-mode-hook}
895 (@pxref{Major Modes}).
896
897 The following sections describe several major modes that are
898 @dfn{derived} from Text mode. These derivatives share most of the
899 features of Text mode described above. In particular, derivatives of
900 Text mode run @code{text-mode-hook} prior to running their own mode
901 hooks.
902
903 @node Outline Mode
904 @section Outline Mode
905 @cindex Outline mode
906 @cindex mode, Outline
907 @cindex invisible lines
908
909 @findex outline-mode
910 @findex outline-minor-mode
911 @vindex outline-minor-mode-prefix
912 @vindex outline-mode-hook
913 Outline mode is a major mode derived from Text mode, which is
914 specialized for editing outlines. It provides commands to navigate
915 between entries in the outline structure, and commands to make parts
916 of a buffer temporarily invisible, so that the outline structure may
917 be more easily viewed. Type @kbd{M-x outline-mode} to switch to
918 Outline mode. Entering Outline mode runs the hook
919 @code{text-mode-hook} followed by the hook @code{outline-mode-hook}
920 (@pxref{Hooks}).
921
922 When you use an Outline mode command to make a line invisible
923 (@pxref{Outline Visibility}), the line disappears from the screen. An
924 ellipsis (three periods in a row) is displayed at the end of the
925 previous visible line, to indicate the hidden text. Multiple
926 consecutive invisible lines produce just one ellipsis.
927
928 Editing commands that operate on lines, such as @kbd{C-n} and
929 @kbd{C-p}, treat the text of the invisible line as part of the
930 previous visible line. Killing the ellipsis at the end of a visible
931 line really kills all the following invisible text associated with the
932 ellipsis.
933
934 Outline minor mode is a buffer-local minor mode which provides the
935 same commands as the major mode, Outline mode, but can be used in
936 conjunction with other major modes. You can type @kbd{M-x
937 outline-minor-mode} to toggle Outline minor mode in the current
938 buffer, or use a file-local variable setting to enable it in a
939 specific file (@pxref{File Variables}).
940
941 @kindex C-c @@ @r{(Outline minor mode)}
942 The major mode, Outline mode, provides special key bindings on the
943 @kbd{C-c} prefix. Outline minor mode provides similar bindings with
944 @kbd{C-c @@} as the prefix; this is to reduce the conflicts with the
945 major mode's special commands. (The variable
946 @code{outline-minor-mode-prefix} controls the prefix used.)
947
948 @menu
949 * Outline Format:: What the text of an outline looks like.
950 * Outline Motion:: Special commands for moving through outlines.
951 * Outline Visibility:: Commands to control what is visible.
952 * Outline Views:: Outlines and multiple views.
953 * Foldout:: Folding means zooming in on outlines.
954 @end menu
955
956 @node Outline Format
957 @subsection Format of Outlines
958
959 @cindex heading lines (Outline mode)
960 @cindex body lines (Outline mode)
961 Outline mode assumes that the lines in the buffer are of two types:
962 @dfn{heading lines} and @dfn{body lines}. A heading line represents a
963 topic in the outline. Heading lines start with one or more asterisk
964 (@samp{*}) characters; the number of asterisks determines the depth of
965 the heading in the outline structure. Thus, a heading line with one
966 @samp{*} is a major topic; all the heading lines with two @samp{*}s
967 between it and the next one-@samp{*} heading are its subtopics; and so
968 on. Any line that is not a heading line is a body line. Body lines
969 belong with the preceding heading line. Here is an example:
970
971 @example
972 * Food
973 This is the body,
974 which says something about the topic of food.
975
976 ** Delicious Food
977 This is the body of the second-level header.
978
979 ** Distasteful Food
980 This could have
981 a body too, with
982 several lines.
983
984 *** Dormitory Food
985
986 * Shelter
987 Another first-level topic with its header line.
988 @end example
989
990 A heading line together with all following body lines is called
991 collectively an @dfn{entry}. A heading line together with all following
992 deeper heading lines and their body lines is called a @dfn{subtree}.
993
994 @vindex outline-regexp
995 You can customize the criterion for distinguishing heading lines by
996 setting the variable @code{outline-regexp}. (The recommended ways to
997 do this are in a major mode function or with a file local variable.)
998 Any line whose beginning has a match for this regexp is considered a
999 heading line. Matches that start within a line (not at the left
1000 margin) do not count.
1001
1002 The length of the matching text determines the level of the heading;
1003 longer matches make a more deeply nested level. Thus, for example, if
1004 a text formatter has commands @samp{@@chapter}, @samp{@@section} and
1005 @samp{@@subsection} to divide the document into chapters and sections,
1006 you could make those lines count as heading lines by setting
1007 @code{outline-regexp} to @samp{"@@chap\\|@@\\(sub\\)*section"}. Note
1008 the trick: the two words @samp{chapter} and @samp{section} are equally
1009 long, but by defining the regexp to match only @samp{chap} we ensure
1010 that the length of the text matched on a chapter heading is shorter,
1011 so that Outline mode will know that sections are contained in
1012 chapters. This works as long as no other command starts with
1013 @samp{@@chap}.
1014
1015 @vindex outline-level
1016 You can explicitly specify a rule for calculating the level of a
1017 heading line by setting the variable @code{outline-level}. The value
1018 of @code{outline-level} should be a function that takes no arguments
1019 and returns the level of the current heading. The recommended ways to
1020 set this variable are in a major mode command or with a file local
1021 variable.
1022
1023 @node Outline Motion
1024 @subsection Outline Motion Commands
1025
1026 Outline mode provides special motion commands that move backward and
1027 forward to heading lines.
1028
1029 @table @kbd
1030 @item C-c C-n
1031 Move point to the next visible heading line
1032 (@code{outline-next-visible-heading}).
1033 @item C-c C-p
1034 Move point to the previous visible heading line
1035 (@code{outline-previous-visible-heading}).
1036 @item C-c C-f
1037 Move point to the next visible heading line at the same level
1038 as the one point is on (@code{outline-forward-same-level}).
1039 @item C-c C-b
1040 Move point to the previous visible heading line at the same level
1041 (@code{outline-backward-same-level}).
1042 @item C-c C-u
1043 Move point up to a lower-level (more inclusive) visible heading line
1044 (@code{outline-up-heading}).
1045 @end table
1046
1047 @findex outline-next-visible-heading
1048 @findex outline-previous-visible-heading
1049 @kindex C-c C-n @r{(Outline mode)}
1050 @kindex C-c C-p @r{(Outline mode)}
1051 @kbd{C-c C-n} (@code{outline-next-visible-heading}) moves down to
1052 the next heading line. @kbd{C-c C-p}
1053 (@code{outline-previous-visible-heading}) moves similarly backward.
1054 Both accept numeric arguments as repeat counts.
1055
1056 @findex outline-up-heading
1057 @findex outline-forward-same-level
1058 @findex outline-backward-same-level
1059 @kindex C-c C-f @r{(Outline mode)}
1060 @kindex C-c C-b @r{(Outline mode)}
1061 @kindex C-c C-u @r{(Outline mode)}
1062 @kbd{C-c C-f} (@code{outline-forward-same-level}) and @kbd{C-c C-b}
1063 (@code{outline-backward-same-level}) move from one heading line to
1064 another visible heading at the same depth in the outline. @kbd{C-c
1065 C-u} (@code{outline-up-heading}) moves backward to another heading
1066 that is less deeply nested.
1067
1068 @node Outline Visibility
1069 @subsection Outline Visibility Commands
1070
1071 Outline mode provides several commands for temporarily hiding or
1072 revealing parts of the buffer, based on the outline structure. These
1073 commands are not undoable; their effects are simply not recorded by
1074 the undo mechanism, so you can undo right past them (@pxref{Undo}).
1075
1076 Many of these commands act on the current heading line. If
1077 point is on a heading line, that is the current heading line; if point
1078 is on a body line, the current heading line is the nearest preceding
1079 header line.
1080
1081 @table @kbd
1082 @item C-c C-c
1083 Make the current heading line's body invisible (@code{hide-entry}).
1084 @item C-c C-e
1085 Make the current heading line's body visible (@code{show-entry}).
1086 @item C-c C-d
1087 Make everything under the current heading invisible, not including the
1088 heading itself (@code{hide-subtree}).
1089 @item C-c C-s
1090 Make everything under the current heading visible, including body,
1091 subheadings, and their bodies (@code{show-subtree}).
1092 @item C-c C-l
1093 Make the body of the current heading line, and of all its subheadings,
1094 invisible (@code{hide-leaves}).
1095 @item C-c C-k
1096 Make all subheadings of the current heading line, at all levels,
1097 visible (@code{show-branches}).
1098 @item C-c C-i
1099 Make immediate subheadings (one level down) of the current heading
1100 line visible (@code{show-children}).
1101 @item C-c C-t
1102 Make all body lines in the buffer invisible (@code{hide-body}).
1103 @item C-c C-a
1104 Make all lines in the buffer visible (@code{show-all}).
1105 @item C-c C-q
1106 Hide everything except the top @var{n} levels of heading lines
1107 (@code{hide-sublevels}).
1108 @item C-c C-o
1109 Hide everything except for the heading or body that point is in, plus
1110 the headings leading up from there to the top level of the outline
1111 (@code{hide-other}).
1112 @end table
1113
1114 @findex hide-entry
1115 @findex show-entry
1116 @kindex C-c C-c @r{(Outline mode)}
1117 @kindex C-c C-e @r{(Outline mode)}
1118 The simplest of these commands are @kbd{C-c C-c}
1119 (@code{hide-entry}), which hides the body lines directly following the
1120 current heading line, and @kbd{C-c C-e} (@code{show-entry}), which
1121 reveals them. Subheadings and their bodies are not affected.
1122
1123 @findex hide-subtree
1124 @findex show-subtree
1125 @kindex C-c C-s @r{(Outline mode)}
1126 @kindex C-c C-d @r{(Outline mode)}
1127 @cindex subtree (Outline mode)
1128 The commands @kbd{C-c C-d} (@code{hide-subtree}) and @kbd{C-c C-s}
1129 (@code{show-subtree}) are more powerful. They apply to the current
1130 heading line's @dfn{subtree}: its body, all of its subheadings, both
1131 direct and indirect, and all of their bodies.
1132
1133 @findex hide-leaves
1134 @findex show-branches
1135 @findex show-children
1136 @kindex C-c C-l @r{(Outline mode)}
1137 @kindex C-c C-k @r{(Outline mode)}
1138 @kindex C-c C-i @r{(Outline mode)}
1139 The command @kbd{C-c C-l} (@code{hide-leaves}) hides the body of the
1140 current heading line as well as all the bodies in its subtree; the
1141 subheadings themselves are left visible. The command @kbd{C-c C-k}
1142 (@code{show-branches}) reveals the subheadings, if they had previously
1143 been hidden (e.g., by @kbd{C-c C-d}). The command @kbd{C-c C-i}
1144 (@code{show-children}) is a weaker version of this; it reveals just
1145 the direct subheadings, i.e., those one level down.
1146
1147 @findex hide-other
1148 @kindex C-c C-o @r{(Outline mode)}
1149 The command @kbd{C-c C-o} (@code{hide-other}) hides everything
1150 except the entry that point is in, plus its parents (the headers
1151 leading up from there to top level in the outline) and the top level
1152 headings.
1153
1154 @findex hide-body
1155 @findex show-all
1156 @kindex C-c C-t @r{(Outline mode)}
1157 @kindex C-c C-a @r{(Outline mode)}
1158 @findex hide-sublevels
1159 @kindex C-c C-q @r{(Outline mode)}
1160 The remaining commands affect the whole buffer. @kbd{C-c C-t}
1161 (@code{hide-body}) makes all body lines invisible, so that you see
1162 just the outline structure (as a special exception, it will not hide
1163 lines at the top of the file, preceding the first header line, even
1164 though these are technically body lines). @kbd{C-c C-a}
1165 (@code{show-all}) makes all lines visible. @kbd{C-c C-q}
1166 (@code{hide-sublevels}) hides all but the top level headings; with a
1167 numeric argument @var{n}, it hides everything except the top @var{n}
1168 levels of heading lines.
1169
1170 @anchor{Outline Search}
1171 @findex reveal-mode
1172 @vindex search-invisible
1173 When incremental search finds text that is hidden by Outline mode,
1174 it makes that part of the buffer visible. If you exit the search at
1175 that position, the text remains visible. To toggle whether or not
1176 an active incremental search can match hidden text, type @kbd{M-s i}.
1177 To change the default for future searches, customize the option
1178 @code{search-invisible}. (This option also affects how @code{query-replace}
1179 and related functions treat hidden text, @pxref{Query Replace}.)
1180 You can also automatically make text visible as you navigate in it by
1181 using Reveal mode (@kbd{M-x reveal-mode}), a buffer-local minor mode.
1182
1183 @node Outline Views
1184 @subsection Viewing One Outline in Multiple Views
1185
1186 @cindex multiple views of outline
1187 @cindex views of an outline
1188 @cindex outline with multiple views
1189 @cindex indirect buffers and outlines
1190 You can display two views of a single outline at the same time, in
1191 different windows. To do this, you must create an indirect buffer using
1192 @kbd{M-x make-indirect-buffer}. The first argument of this command is
1193 the existing outline buffer name, and its second argument is the name to
1194 use for the new indirect buffer. @xref{Indirect Buffers}.
1195
1196 Once the indirect buffer exists, you can display it in a window in the
1197 normal fashion, with @kbd{C-x 4 b} or other Emacs commands. The Outline
1198 mode commands to show and hide parts of the text operate on each buffer
1199 independently; as a result, each buffer can have its own view. If you
1200 want more than two views on the same outline, create additional indirect
1201 buffers.
1202
1203 @node Foldout
1204 @subsection Folding Editing
1205
1206 @cindex folding editing
1207 The Foldout package extends Outline mode and Outline minor mode with
1208 folding commands. The idea of folding is that you zoom in on a
1209 nested portion of the outline, while hiding its relatives at higher
1210 levels.
1211
1212 Consider an Outline mode buffer with all the text and subheadings under
1213 level-1 headings hidden. To look at what is hidden under one of these
1214 headings, you could use @kbd{C-c C-e} (@kbd{M-x show-entry}) to expose
1215 the body, or @kbd{C-c C-i} to expose the child (level-2) headings.
1216
1217 @kindex C-c C-z
1218 @findex foldout-zoom-subtree
1219 With Foldout, you use @kbd{C-c C-z} (@kbd{M-x foldout-zoom-subtree}).
1220 This exposes the body and child subheadings, and narrows the buffer so
1221 that only the @w{level-1} heading, the body and the level-2 headings are
1222 visible. Now to look under one of the level-2 headings, position the
1223 cursor on it and use @kbd{C-c C-z} again. This exposes the level-2 body
1224 and its level-3 child subheadings and narrows the buffer again. Zooming
1225 in on successive subheadings can be done as much as you like. A string
1226 in the mode line shows how deep you've gone.
1227
1228 When zooming in on a heading, to see only the child subheadings specify
1229 a numeric argument: @kbd{C-u C-c C-z}. The number of levels of children
1230 can be specified too (compare @kbd{M-x show-children}), e.g., @kbd{M-2
1231 C-c C-z} exposes two levels of child subheadings. Alternatively, the
1232 body can be specified with a negative argument: @kbd{M-- C-c C-z}. The
1233 whole subtree can be expanded, similarly to @kbd{C-c C-s} (@kbd{M-x
1234 show-subtree}), by specifying a zero argument: @kbd{M-0 C-c C-z}.
1235
1236 While you're zoomed in, you can still use Outline mode's exposure and
1237 hiding functions without disturbing Foldout. Also, since the buffer is
1238 narrowed, global editing actions will only affect text under the
1239 zoomed-in heading. This is useful for restricting changes to a
1240 particular chapter or section of your document.
1241
1242 @kindex C-c C-x
1243 @findex foldout-exit-fold
1244 To unzoom (exit) a fold, use @kbd{C-c C-x} (@kbd{M-x foldout-exit-fold}).
1245 This hides all the text and subheadings under the top-level heading and
1246 returns you to the previous view of the buffer. Specifying a numeric
1247 argument exits that many levels of folds. Specifying a zero argument
1248 exits all folds.
1249
1250 To cancel the narrowing of a fold without hiding the text and
1251 subheadings, specify a negative argument. For example, @kbd{M--2 C-c
1252 C-x} exits two folds and leaves the text and subheadings exposed.
1253
1254 Foldout mode also provides mouse commands for entering and exiting
1255 folds, and for showing and hiding text:
1256
1257 @table @asis
1258 @item @kbd{C-M-mouse-1} zooms in on the heading clicked on
1259 @itemize @w{}
1260 @item
1261 single click: expose body.
1262 @item
1263 double click: expose subheadings.
1264 @item
1265 triple click: expose body and subheadings.
1266 @item
1267 quad click: expose entire subtree.
1268 @end itemize
1269 @item @kbd{C-M-mouse-2} exposes text under the heading clicked on
1270 @itemize @w{}
1271 @item
1272 single click: expose body.
1273 @item
1274 double click: expose subheadings.
1275 @item
1276 triple click: expose body and subheadings.
1277 @item
1278 quad click: expose entire subtree.
1279 @end itemize
1280 @item @kbd{C-M-mouse-3} hides text under the heading clicked on or exits fold
1281 @itemize @w{}
1282 @item
1283 single click: hide subtree.
1284 @item
1285 double click: exit fold and hide text.
1286 @item
1287 triple click: exit fold without hiding text.
1288 @item
1289 quad click: exit all folds and hide text.
1290 @end itemize
1291 @end table
1292
1293 @c FIXME not marked as a user variable
1294 @vindex foldout-mouse-modifiers
1295 You can specify different modifier keys (instead of
1296 @kbd{@key{Ctrl}-@key{META}-}) by setting @code{foldout-mouse-modifiers}; but if
1297 you have already loaded the @file{foldout.el} library, you must reload
1298 it in order for this to take effect.
1299
1300 To use the Foldout package, you can type @kbd{M-x load-library
1301 @key{RET} foldout @key{RET}}; or you can arrange for to do that
1302 automatically by putting the following in your init file:
1303
1304 @example
1305 (eval-after-load "outline" '(require 'foldout))
1306 @end example
1307
1308 @node Org Mode
1309 @section Org Mode
1310 @cindex organizer
1311 @cindex planner
1312 @findex Org mode
1313 @findex mode, Org
1314
1315 @findex org-mode
1316 Org mode is a variant of Outline mode for using Emacs as an
1317 organizer and/or authoring system. Files with names ending in the
1318 extension @file{.org} are opened in Org mode (@pxref{Choosing Modes}).
1319 To explicitly switch to Org mode, type @kbd{M-x org-mode}.
1320
1321 In Org mode, as in Outline mode, each entry has a heading line that
1322 starts with one or more @samp{*} characters. @xref{Outline Format}.
1323 In addition, any line that begins with the @samp{#} character is
1324 treated as a comment.
1325
1326 @kindex TAB @r{(Org Mode)}
1327 @findex org-cycle
1328 Org mode provides commands for easily viewing and manipulating the
1329 outline structure. The simplest of these commands is @key{TAB}
1330 (@code{org-cycle}). If invoked on a heading line, it cycles through
1331 the different visibility states of the subtree: (i) showing only that
1332 heading line, (ii) showing only the heading line and the heading lines
1333 of its direct children, if any, and (iii) showing the entire subtree.
1334 If invoked in a body line, the global binding for @key{TAB} is
1335 executed.
1336
1337 @kindex S-TAB @r{(Org Mode)}
1338 @findex org-shifttab
1339 Typing @kbd{S-@key{TAB}} (@code{org-shifttab}) anywhere in an Org mode
1340 buffer cycles the visibility of the entire outline structure, between
1341 (i) showing only top-level heading lines, (ii) showing all heading
1342 lines but no body lines, and (iii) showing everything.
1343
1344 @kindex M-<up> @r{(Org Mode)}
1345 @kindex M-<down> @r{(Org Mode)}
1346 @kindex M-<left> @r{(Org Mode)}
1347 @kindex M-<right> @r{(Org Mode)}
1348 @findex org-metaup
1349 @findex org-metadown
1350 @findex org-metaleft
1351 @findex org-metaright
1352 You can move an entire entry up or down in the buffer, including its
1353 body lines and subtree (if any), by typing @kbd{M-<up>}
1354 (@code{org-metaup}) or @kbd{M-<down>} (@code{org-metadown}) on the
1355 heading line. Similarly, you can promote or demote a heading line
1356 with @kbd{M-<left>} (@code{org-metaleft}) and @kbd{M-<right>}
1357 (@code{org-metaright}). These commands execute their global bindings
1358 if invoked on a body line.
1359
1360 The following subsections give basic instructions for using Org mode
1361 as an organizer and as an authoring system. For details, @pxref{Top,
1362 The Org Mode Manual, Introduction, org, The Org Manual}.
1363
1364 @menu
1365 * Org Organizer:: Managing TODO lists and agendas.
1366 * Org Authoring:: Exporting Org buffers to various formats.
1367 @end menu
1368
1369 @node Org Organizer
1370 @subsection Org as an organizer
1371 @cindex TODO item
1372 @cindex Org agenda
1373
1374 @kindex C-c C-t @r{(Org Mode)}
1375 @findex org-todo
1376 @vindex org-todo-keywords
1377 You can tag an Org entry as a @dfn{TODO} item by typing @kbd{C-c
1378 C-t} (@code{org-todo}) anywhere in the entry. This adds the keyword
1379 @samp{TODO} to the heading line. Typing @kbd{C-c C-t} again switches
1380 the keyword to @samp{DONE}; another @kbd{C-c C-t} removes the keyword
1381 entirely, and so forth. You can customize the keywords used by
1382 @kbd{C-c C-t} via the variable @code{org-todo-keywords}.
1383
1384 @kindex C-c C-s @r{(Org Mode)}
1385 @kindex C-c C-d @r{(Org Mode)}
1386 @findex org-schedule
1387 @findex org-deadline
1388 Apart from marking an entry as TODO, you can attach a date to it, by
1389 typing @kbd{C-c C-s} (@code{org-schedule}) in the entry. This prompts
1390 for a date by popping up the Emacs Calendar (@pxref{Calendar/Diary}),
1391 and then adds the tag @samp{SCHEDULED}, together with the selected
1392 date, beneath the heading line. The command @kbd{C-c C-d}
1393 (@code{org-deadline}) has the same effect, except that it uses the tag
1394 @code{DEADLINE}.
1395
1396 @kindex C-c [ @r{(Org Mode)}
1397 @findex org-agenda-file-to-front
1398 @vindex org-agenda-files
1399 Once you have some TODO items planned in an Org file, you can add
1400 that file to the list of @dfn{agenda files} by typing @kbd{C-c [}
1401 (@code{org-agenda-file-to-front}). Org mode is designed to let you
1402 easily maintain multiple agenda files, e.g., for organizing different
1403 aspects of your life. The list of agenda files is stored in the
1404 variable @code{org-agenda-files}.
1405
1406 @findex org-agenda
1407 To view items coming from your agenda files, type @kbd{M-x
1408 org-agenda}. This command prompts for what you want to see: a list of
1409 things to do this week, a list of TODO items with specific keywords,
1410 etc.
1411 @ifnottex
1412 @xref{Agenda Views,,,org, The Org Manual}, for details.
1413 @end ifnottex
1414
1415 @node Org Authoring
1416 @subsection Org as an authoring system
1417 @cindex Org exporting
1418
1419 @findex org-export
1420 @kindex C-c C-e @r{(Org mode)}
1421 You may want to format your Org notes nicely and to prepare them for
1422 export and publication. To export the current buffer, type @kbd{C-c
1423 C-e} (@code{org-export}) anywhere in an Org buffer. This command
1424 prompts for an export format; currently supported formats include
1425 HTML, @LaTeX{}, OpenDocument (@file{.odt}), and PDF@. Some formats,
1426 such as PDF, require certain system tools to be installed.
1427
1428 @vindex org-publish-project-alist
1429 To export several files at once to a specific directory, either
1430 locally or over the network, you must define a list of projects
1431 through the variable @code{org-publish-project-alist}. See its
1432 documentation for details.
1433
1434 Org supports a simple markup scheme for applying text formatting to
1435 exported documents:
1436
1437 @example
1438 - This text is /emphasized/
1439 - This text is *in bold*
1440 - This text is _underlined_
1441 - This text uses =a teletype font=
1442
1443 #+begin_quote
1444 ``This is a quote.''
1445 #+end_quote
1446
1447 #+begin_example
1448 This is an example.
1449 #+end_example
1450 @end example
1451
1452 For further details, @ref{Exporting,,,org, The Org Manual}, and
1453 @ref{Publishing,,,org, The Org Manual}.
1454
1455 @node TeX Mode
1456 @section @TeX{} Mode
1457 @cindex @TeX{} mode
1458 @cindex @LaTeX{} mode
1459 @cindex Sli@TeX{} mode
1460 @cindex Doc@TeX{} mode
1461 @cindex mode, @TeX{}
1462 @cindex mode, @LaTeX{}
1463 @cindex mode, Sli@TeX{}
1464 @cindex mode, Doc@TeX{}
1465 @findex tex-mode
1466 @findex plain-tex-mode
1467 @findex latex-mode
1468 @findex slitex-mode
1469 @findex doctex-mode
1470 @findex bibtex-mode
1471
1472 Emacs provides special major modes for editing files written in
1473 @TeX{} and its related formats. @TeX{} is a powerful text formatter
1474 written by Donald Knuth; like GNU Emacs, it is free software.
1475 @LaTeX{} is a simplified input format for @TeX{}, implemented using
1476 @TeX{} macros. Doc@TeX{} is a special file format in which the
1477 @LaTeX{} sources are written, combining sources with documentation.
1478 Sli@TeX{} is an obsolete special form of @LaTeX{}.@footnote{It has
1479 been replaced by the @samp{slides} document class, which comes with
1480 @LaTeX{}.}
1481
1482 @vindex tex-default-mode
1483 @TeX{} mode has four variants: Plain @TeX{} mode, @LaTeX{} mode,
1484 Doc@TeX{} mode, and Sli@TeX{} mode. These distinct major modes differ
1485 only slightly, and are designed for editing the four different
1486 formats. Emacs selects the appropriate mode by looking at the
1487 contents of the buffer. (This is done by the @code{tex-mode} command,
1488 which is normally called automatically when you visit a @TeX{}-like
1489 file. @xref{Choosing Modes}.) If the contents are insufficient to
1490 determine this, Emacs chooses the mode specified by the variable
1491 @code{tex-default-mode}; its default value is @code{latex-mode}. If
1492 Emacs does not guess right, you can select the correct variant of
1493 @TeX{} mode using the command @kbd{M-x plain-tex-mode}, @kbd{M-x
1494 latex-mode}, @kbd{M-x slitex-mode}, or @kbd{doctex-mode}.
1495
1496 The following sections document the features of @TeX{} mode and its
1497 variants. There are several other @TeX{}-related Emacs packages,
1498 which are not documented in this manual:
1499
1500 @itemize @bullet
1501 @item
1502 Bib@TeX{} mode is a major mode for Bib@TeX{} files, which are commonly
1503 used for keeping bibliographic references for @LaTeX{} documents. For
1504 more information, see the documentation string for the command
1505 @code{bibtex-mode}.
1506
1507 @item
1508 The Ref@TeX{} package provides a minor mode which can be used with
1509 @LaTeX{} mode to manage bibliographic references.
1510 @ifinfo
1511 @xref{Top,The Ref@TeX{} Manual,,reftex}.
1512 @end ifinfo
1513 @ifnotinfo
1514 For more information, see the Ref@TeX{} Info manual, which is
1515 distributed with Emacs.
1516 @end ifnotinfo
1517
1518 @item
1519 The AUC@TeX{} package provides more advanced features for editing
1520 @TeX{} and its related formats, including the ability to preview
1521 @TeX{} equations within Emacs buffers. Unlike Bib@TeX{} mode and the
1522 Ref@TeX{} package, AUC@TeX{} is not distributed with Emacs by default.
1523 It can be downloaded via the Package Menu (@pxref{Packages}); once
1524 installed, see
1525 @ifinfo
1526 @ref{Top,The AUC@TeX{} Manual,,auctex}.
1527 @end ifinfo
1528 @ifnotinfo
1529 the AUC@TeX{} manual, which is included with the package.
1530 @end ifnotinfo
1531 @end itemize
1532
1533 @menu
1534 * TeX Editing:: Special commands for editing in TeX mode.
1535 * LaTeX Editing:: Additional commands for LaTeX input files.
1536 * TeX Print:: Commands for printing part of a file with TeX.
1537 * TeX Misc:: Customization of TeX mode, and related features.
1538 @end menu
1539
1540 @node TeX Editing
1541 @subsection @TeX{} Editing Commands
1542
1543 @table @kbd
1544 @item "
1545 Insert, according to context, either @samp{``} or @samp{"} or
1546 @samp{''} (@code{tex-insert-quote}).
1547 @item C-j
1548 Insert a paragraph break (two newlines) and check the previous
1549 paragraph for unbalanced braces or dollar signs
1550 (@code{tex-terminate-paragraph}).
1551 @item M-x tex-validate-region
1552 Check each paragraph in the region for unbalanced braces or dollar signs.
1553 @item C-c @{
1554 Insert @samp{@{@}} and position point between them (@code{tex-insert-braces}).
1555 @item C-c @}
1556 Move forward past the next unmatched close brace (@code{up-list}).
1557 @end table
1558
1559 @findex tex-insert-quote
1560 @kindex " @r{(@TeX{} mode)}
1561 In @TeX{}, the character @samp{"} is not normally used; instead,
1562 quotations begin with @samp{``} and end with @samp{''}. @TeX{} mode
1563 therefore binds the @kbd{"} key to the @code{tex-insert-quote}
1564 command. This inserts @samp{``} after whitespace or an open brace,
1565 @samp{"} after a backslash, and @samp{''} after any other character.
1566
1567 As a special exception, if you type @kbd{"} when the text before
1568 point is either @samp{``} or @samp{''}, Emacs replaces that preceding
1569 text with a single @samp{"} character. You can therefore type
1570 @kbd{""} to insert @samp{"}, should you ever need to do so. (You can
1571 also use @kbd{C-q "} to insert this character.)
1572
1573 In @TeX{} mode, @samp{$} has a special syntax code which attempts to
1574 understand the way @TeX{} math mode delimiters match. When you insert a
1575 @samp{$} that is meant to exit math mode, the position of the matching
1576 @samp{$} that entered math mode is displayed for a second. This is the
1577 same feature that displays the open brace that matches a close brace that
1578 is inserted. However, there is no way to tell whether a @samp{$} enters
1579 math mode or leaves it; so when you insert a @samp{$} that enters math
1580 mode, the previous @samp{$} position is shown as if it were a match, even
1581 though they are actually unrelated.
1582
1583 @findex tex-insert-braces
1584 @kindex C-c @{ @r{(@TeX{} mode)}
1585 @findex up-list
1586 @kindex C-c @} @r{(@TeX{} mode)}
1587 @TeX{} uses braces as delimiters that must match. Some users prefer
1588 to keep braces balanced at all times, rather than inserting them
1589 singly. Use @kbd{C-c @{} (@code{tex-insert-braces}) to insert a pair of
1590 braces. It leaves point between the two braces so you can insert the
1591 text that belongs inside. Afterward, use the command @kbd{C-c @}}
1592 (@code{up-list}) to move forward past the close brace.
1593
1594 @findex tex-validate-region
1595 @findex tex-terminate-paragraph
1596 @kindex C-j @r{(@TeX{} mode)}
1597 There are two commands for checking the matching of braces.
1598 @kbd{C-j} (@code{tex-terminate-paragraph}) checks the paragraph before
1599 point, and inserts two newlines to start a new paragraph. It outputs
1600 a message in the echo area if any mismatch is found. @kbd{M-x
1601 tex-validate-region} checks a region, paragraph by paragraph. The
1602 errors are listed in an @file{*Occur*} buffer; you can use the usual
1603 Occur mode commands in that buffer, such as @kbd{C-c C-c}, to visit a
1604 particular mismatch (@pxref{Other Repeating Search}).
1605
1606 Note that Emacs commands count square brackets and parentheses in
1607 @TeX{} mode, not just braces. This is not strictly correct for the
1608 purpose of checking @TeX{} syntax. However, parentheses and square
1609 brackets are likely to be used in text as matching delimiters, and it
1610 is useful for the various motion commands and automatic match display
1611 to work with them.
1612
1613 @node LaTeX Editing
1614 @subsection @LaTeX{} Editing Commands
1615
1616 @LaTeX{} mode provides a few extra features not applicable to plain
1617 @TeX{}:
1618
1619 @table @kbd
1620 @item C-c C-o
1621 Insert @samp{\begin} and @samp{\end} for @LaTeX{} block and position
1622 point on a line between them (@code{tex-latex-block}).
1623 @item C-c C-e
1624 Close the innermost @LaTeX{} block not yet closed
1625 (@code{tex-close-latex-block}).
1626 @end table
1627
1628 @findex tex-latex-block
1629 @kindex C-c C-o @r{(@LaTeX{} mode)}
1630 In @LaTeX{} input, @samp{\begin} and @samp{\end} tags are used to
1631 group blocks of text. To insert a block, type @kbd{C-c C-o}
1632 (@code{tex-latex-block}). This prompts for a block type, and inserts
1633 the appropriate matching @samp{\begin} and @samp{\end} tags, leaving a
1634 blank line between the two and moving point there.
1635
1636 @vindex latex-block-names
1637 When entering the block type argument to @kbd{C-c C-o}, you can use
1638 the usual completion commands (@pxref{Completion}). The default
1639 completion list contains the standard @LaTeX{} block types. If you
1640 want additional block types for completion, customize the list
1641 variable @code{latex-block-names}.
1642
1643 @findex tex-close-latex-block
1644 @kindex C-c C-e @r{(@LaTeX{} mode)}
1645 @findex latex-electric-env-pair-mode
1646 In @LaTeX{} input, @samp{\begin} and @samp{\end} tags must balance.
1647 You can use @kbd{C-c C-e} (@code{tex-close-latex-block}) to insert an
1648 @samp{\end} tag which matches the last unmatched @samp{\begin}. It
1649 also indents the @samp{\end} to match the corresponding @samp{\begin},
1650 and inserts a newline after the @samp{\end} tag if point is at the
1651 beginning of a line. The minor mode @code{latex-electric-env-pair-mode}
1652 automatically inserts an @samp{\end} or @samp{\begin} tag for you
1653 when you type the corresponding one.
1654
1655 @node TeX Print
1656 @subsection @TeX{} Printing Commands
1657
1658 You can invoke @TeX{} as an subprocess of Emacs, supplying either
1659 the entire contents of the buffer or just part of it (e.g., one
1660 chapter of a larger document).
1661
1662 @table @kbd
1663 @item C-c C-b
1664 Invoke @TeX{} on the entire current buffer (@code{tex-buffer}).
1665 @item C-c C-r
1666 Invoke @TeX{} on the current region, together with the buffer's header
1667 (@code{tex-region}).
1668 @item C-c C-f
1669 Invoke @TeX{} on the current file (@code{tex-file}).
1670
1671 @item C-c C-v
1672 Preview the output from the last @kbd{C-c C-r}, @kbd{C-c C-b}, or @kbd{C-c
1673 C-f} command (@code{tex-view}).
1674
1675 @item C-c C-p
1676 Print the output from the last @kbd{C-c C-b}, @kbd{C-c C-r}, or
1677 @kbd{C-c C-f} command (@code{tex-print}).
1678
1679 @item C-c @key{TAB}
1680 Invoke Bib@TeX{} on the current file (@code{tex-bibtex-file}).
1681 @item C-c C-l
1682 Recenter the window showing output from @TeX{} so that the last line
1683 can be seen (@code{tex-recenter-output-buffer}).
1684 @item C-c C-k
1685 Kill the @TeX{} subprocess (@code{tex-kill-job}).
1686 @item C-c C-c
1687 Invoke some other compilation command on the entire current buffer
1688 (@code{tex-compile}).
1689 @end table
1690
1691 @findex tex-buffer
1692 @kindex C-c C-b @r{(@TeX{} mode)}
1693 @findex tex-view
1694 @kindex C-c C-v @r{(@TeX{} mode)}
1695 @findex tex-print
1696 @kindex C-c C-p @r{(@TeX{} mode)}
1697 To pass the current buffer through @TeX{}, type @kbd{C-c C-b}
1698 (@code{tex-buffer}). The formatted output goes in a temporary file,
1699 normally a @file{.dvi} file. Afterwards, you can type @kbd{C-c C-v}
1700 (@code{tex-view}) to launch an external program, such as
1701 @command{xdvi}, to view this output file. You can also type @kbd{C-c
1702 C-p} (@code{tex-print}) to print a hardcopy of the output file.
1703
1704 @cindex @env{TEXINPUTS} environment variable
1705 @vindex tex-directory
1706 By default, @kbd{C-c C-b} runs @TeX{} in the current directory. The
1707 output of @TeX{} also goes in this directory. To run @TeX{} in a
1708 different directory, change the variable @code{tex-directory} to the
1709 desired directory name. If your environment variable @env{TEXINPUTS}
1710 contains relative directory names, or if your files contains
1711 @samp{\input} commands with relative file names, then
1712 @code{tex-directory} @emph{must} be @code{"."} or you will get the
1713 wrong results. Otherwise, it is safe to specify some other directory,
1714 such as @code{"/tmp"}.
1715
1716 @vindex tex-run-command
1717 @vindex latex-run-command
1718 @vindex tex-dvi-view-command
1719 @vindex tex-dvi-print-command
1720 @vindex tex-print-file-extension
1721 The buffer's @TeX{} variant determines what shell command @kbd{C-c
1722 C-b} actually runs. In Plain @TeX{} mode, it is specified by the
1723 variable @code{tex-run-command}, which defaults to @code{"tex"}. In
1724 @LaTeX{} mode, it is specified by @code{latex-run-command}, which
1725 defaults to @code{"latex"}. The shell command that @kbd{C-c C-v} runs
1726 to view the @file{.dvi} output is determined by the variable
1727 @code{tex-dvi-view-command}, regardless of the @TeX{} variant. The
1728 shell command that @kbd{C-c C-p} runs to print the output is
1729 determined by the variable @code{tex-dvi-print-command}. The variable
1730 @code{tex-print-file-extension} can be set to the required file
1731 extension for viewing and printing @TeX{}-compiled files. For
1732 example, you can set it to @file{.pdf}, and update
1733 @code{tex-dvi-view-command} and @code{tex-dvi-print-command}
1734 accordingly.
1735
1736 Normally, Emacs automatically appends the output file name to the
1737 shell command strings described in the preceding paragraph. For
1738 example, if @code{tex-dvi-view-command} is @code{"xdvi"}, @kbd{C-c
1739 C-v} runs @command{xdvi @var{output-file-name}}. In some cases,
1740 however, the file name needs to be embedded in the command, e.g., if
1741 you need to provide the file name as an argument to one command whose
1742 output is piped to another. You can specify where to put the file
1743 name with @samp{*} in the command string. For example,
1744
1745 @example
1746 (setq tex-dvi-print-command "dvips -f * | lpr")
1747 @end example
1748
1749 @findex tex-kill-job
1750 @kindex C-c C-k @r{(@TeX{} mode)}
1751 @findex tex-recenter-output-buffer
1752 @kindex C-c C-l @r{(@TeX{} mode)}
1753 The terminal output from @TeX{}, including any error messages,
1754 appears in a buffer called @file{*tex-shell*}. If @TeX{} gets an
1755 error, you can switch to this buffer and feed it input (this works as
1756 in Shell mode; @pxref{Interactive Shell}). Without switching to this
1757 buffer you can scroll it so that its last line is visible by typing
1758 @kbd{C-c C-l}.
1759
1760 Type @kbd{C-c C-k} (@code{tex-kill-job}) to kill the @TeX{} process if
1761 you see that its output is no longer useful. Using @kbd{C-c C-b} or
1762 @kbd{C-c C-r} also kills any @TeX{} process still running.
1763
1764 @findex tex-region
1765 @kindex C-c C-r @r{(@TeX{} mode)}
1766 You can also pass an arbitrary region through @TeX{} by typing
1767 @kbd{C-c C-r} (@code{tex-region}). This is tricky, however, because
1768 most files of @TeX{} input contain commands at the beginning to set
1769 parameters and define macros, without which no later part of the file
1770 will format correctly. To solve this problem, @kbd{C-c C-r} allows
1771 you to designate a part of the file as containing essential commands;
1772 it is included before the specified region as part of the input to
1773 @TeX{}. The designated part of the file is called the @dfn{header}.
1774
1775 @cindex header (@TeX{} mode)
1776 To indicate the bounds of the header in Plain @TeX{} mode, you insert two
1777 special strings in the file. Insert @samp{%**start of header} before the
1778 header, and @samp{%**end of header} after it. Each string must appear
1779 entirely on one line, but there may be other text on the line before or
1780 after. The lines containing the two strings are included in the header.
1781 If @samp{%**start of header} does not appear within the first 100 lines of
1782 the buffer, @kbd{C-c C-r} assumes that there is no header.
1783
1784 In @LaTeX{} mode, the header begins with @samp{\documentclass} or
1785 @samp{\documentstyle} and ends with @samp{\begin@{document@}}. These
1786 are commands that @LaTeX{} requires you to use in any case, so nothing
1787 special needs to be done to identify the header.
1788
1789 @findex tex-file
1790 @kindex C-c C-f @r{(@TeX{} mode)}
1791 The commands (@code{tex-buffer}) and (@code{tex-region}) do all of their
1792 work in a temporary directory, and do not have available any of the auxiliary
1793 files needed by @TeX{} for cross-references; these commands are generally
1794 not suitable for running the final copy in which all of the cross-references
1795 need to be correct.
1796
1797 When you want the auxiliary files for cross references, use @kbd{C-c
1798 C-f} (@code{tex-file}) which runs @TeX{} on the current buffer's file,
1799 in that file's directory. Before running @TeX{}, it offers to save any
1800 modified buffers. Generally, you need to use (@code{tex-file}) twice to
1801 get the cross-references right.
1802
1803 @vindex tex-start-options
1804 The value of the variable @code{tex-start-options} specifies
1805 options for the @TeX{} run.
1806
1807 @vindex tex-start-commands
1808 The value of the variable @code{tex-start-commands} specifies @TeX{}
1809 commands for starting @TeX{}. The default value causes @TeX{} to run
1810 in nonstop mode. To run @TeX{} interactively, set the variable to
1811 @code{""}.
1812
1813 @vindex tex-main-file
1814 Large @TeX{} documents are often split into several files---one main
1815 file, plus subfiles. Running @TeX{} on a subfile typically does not
1816 work; you have to run it on the main file. In order to make
1817 @code{tex-file} useful when you are editing a subfile, you can set the
1818 variable @code{tex-main-file} to the name of the main file. Then
1819 @code{tex-file} runs @TeX{} on that file.
1820
1821 The most convenient way to use @code{tex-main-file} is to specify it
1822 in a local variable list in each of the subfiles. @xref{File
1823 Variables}.
1824
1825 @findex tex-bibtex-file
1826 @kindex C-c TAB @r{(@TeX{} mode)}
1827 @vindex tex-bibtex-command
1828 For @LaTeX{} files, you can use Bib@TeX{} to process the auxiliary
1829 file for the current buffer's file. Bib@TeX{} looks up bibliographic
1830 citations in a data base and prepares the cited references for the
1831 bibliography section. The command @kbd{C-c @key{TAB}}
1832 (@code{tex-bibtex-file}) runs the shell command
1833 (@code{tex-bibtex-command}) to produce a @samp{.bbl} file for the
1834 current buffer's file. Generally, you need to do @kbd{C-c C-f}
1835 (@code{tex-file}) once to generate the @samp{.aux} file, then do
1836 @kbd{C-c @key{TAB}} (@code{tex-bibtex-file}), and then repeat @kbd{C-c C-f}
1837 (@code{tex-file}) twice more to get the cross-references correct.
1838
1839 @findex tex-compile
1840 @kindex C-c C-c @r{(@TeX{} mode)}
1841 To invoke some other compilation program on the current @TeX{}
1842 buffer, type @kbd{C-c C-c} (@code{tex-compile}). This command knows
1843 how to pass arguments to many common programs, including
1844 @file{pdflatex}, @file{yap}, @file{xdvi}, and @file{dvips}. You can
1845 select your desired compilation program using the standard completion
1846 keys (@pxref{Completion}).
1847
1848 @node TeX Misc
1849 @subsection @TeX{} Mode Miscellany
1850
1851 @vindex tex-shell-hook
1852 @vindex tex-mode-hook
1853 @vindex latex-mode-hook
1854 @vindex slitex-mode-hook
1855 @vindex plain-tex-mode-hook
1856 Entering any variant of @TeX{} mode runs the hooks
1857 @code{text-mode-hook} and @code{tex-mode-hook}. Then it runs either
1858 @code{plain-tex-mode-hook}, @code{latex-mode-hook}, or
1859 @code{slitex-mode-hook}, whichever is appropriate. Starting the
1860 @TeX{} shell runs the hook @code{tex-shell-hook}. @xref{Hooks}.
1861
1862 @findex iso-iso2tex
1863 @findex iso-tex2iso
1864 @findex iso-iso2gtex
1865 @findex iso-gtex2iso
1866 @cindex Latin-1 @TeX{} encoding
1867 @cindex @TeX{} encoding
1868 The commands @kbd{M-x iso-iso2tex}, @kbd{M-x iso-tex2iso}, @kbd{M-x
1869 iso-iso2gtex} and @kbd{M-x iso-gtex2iso} can be used to convert
1870 between Latin-1 encoded files and @TeX{}-encoded equivalents.
1871
1872 @node HTML Mode
1873 @section SGML and HTML Modes
1874 @cindex SGML mode
1875 @cindex HTML mode
1876 @cindex mode, SGML
1877 @cindex mode, HTML
1878 @findex sgml-mode
1879 @findex html-mode
1880
1881 The major modes for SGML and HTML provide indentation support and
1882 commands for operating on tags. HTML mode is a slightly customized
1883 variant of SGML mode.
1884
1885 @table @kbd
1886 @item C-c C-n
1887 @kindex C-c C-n @r{(SGML mode)}
1888 @findex sgml-name-char
1889 Interactively specify a special character and insert the SGML
1890 @samp{&}-command for that character (@code{sgml-name-char}).
1891
1892 @item C-c C-t
1893 @kindex C-c C-t @r{(SGML mode)}
1894 @findex sgml-tag
1895 Interactively specify a tag and its attributes (@code{sgml-tag}).
1896 This command asks you for a tag name and for the attribute values,
1897 then inserts both the opening tag and the closing tag, leaving point
1898 between them.
1899
1900 With a prefix argument @var{n}, the command puts the tag around the
1901 @var{n} words already present in the buffer after point. Whenever a
1902 region is active, it puts the tag around the region (when Transient
1903 Mark mode is off, it does this when a numeric argument of @minus{}1 is
1904 supplied.)
1905
1906 @item C-c C-a
1907 @kindex C-c C-a @r{(SGML mode)}
1908 @findex sgml-attributes
1909 Interactively insert attribute values for the current tag
1910 (@code{sgml-attributes}).
1911
1912 @item C-c C-f
1913 @kindex C-c C-f @r{(SGML mode)}
1914 @findex sgml-skip-tag-forward
1915 Skip across a balanced tag group (which extends from an opening tag
1916 through its corresponding closing tag) (@code{sgml-skip-tag-forward}).
1917 A numeric argument acts as a repeat count.
1918
1919 @item C-c C-b
1920 @kindex C-c C-b @r{(SGML mode)}
1921 @findex sgml-skip-tag-backward
1922 Skip backward across a balanced tag group (which extends from an
1923 opening tag through its corresponding closing tag)
1924 (@code{sgml-skip-tag-backward}). A numeric argument acts as a repeat
1925 count.
1926
1927 @item C-c C-d
1928 @kindex C-c C-d @r{(SGML mode)}
1929 @findex sgml-delete-tag
1930 Delete the tag at or after point, and delete the matching tag too
1931 (@code{sgml-delete-tag}). If the tag at or after point is an opening
1932 tag, delete the closing tag too; if it is a closing tag, delete the
1933 opening tag too.
1934
1935 @item C-c ? @var{tag} @key{RET}
1936 @kindex C-c ? @r{(SGML mode)}
1937 @findex sgml-tag-help
1938 Display a description of the meaning of tag @var{tag}
1939 (@code{sgml-tag-help}). If the argument @var{tag} is empty, describe
1940 the tag at point.
1941
1942 @item C-c /
1943 @kindex C-c / @r{(SGML mode)}
1944 @findex sgml-close-tag
1945 Insert a close tag for the innermost unterminated tag
1946 (@code{sgml-close-tag}). If called within a tag or a comment,
1947 close it instead of inserting a close tag.
1948
1949 @item C-c 8
1950 @kindex C-c 8 @r{(SGML mode)}
1951 @findex sgml-name-8bit-mode
1952 Toggle a minor mode in which Latin-1 characters insert the
1953 corresponding SGML commands that stand for them, instead of the
1954 characters themselves (@code{sgml-name-8bit-mode}).
1955
1956 @item C-c C-v
1957 @kindex C-c C-v @r{(SGML mode)}
1958 @findex sgml-validate
1959 Run a shell command (which you must specify) to validate the current
1960 buffer as SGML (@code{sgml-validate}).
1961
1962 @item C-c @key{TAB}
1963 @kindex C-c TAB @r{(SGML mode)}
1964 @findex sgml-tags-invisible
1965 Toggle the visibility of existing tags in the buffer. This can be
1966 used as a cheap preview (@code{sgml-tags-invisible}).
1967 @end table
1968
1969 @cindex nXML mode
1970 @cindex mode, nXML
1971 @findex nxml-mode
1972 @cindex XML schema
1973 The major mode for editing XML documents is called nXML mode. This
1974 is a powerful major mode that can recognize many existing XML schema
1975 and use them to provide completion of XML elements via
1976 @kbd{M-@key{TAB}}, as well as on-the-fly XML
1977 validation with error highlighting. To enable nXML mode in an
1978 existing buffer, type @kbd{M-x nxml-mode}, or, equivalently, @kbd{M-x
1979 xml-mode}. Emacs uses nXML mode for files which have the extension
1980 @file{.xml}. For XHTML files, which have the extension @file{.xhtml},
1981 Emacs uses HTML mode by default; you can make it use nXML mode by
1982 customizing the variable @code{auto-mode-alist} (@pxref{Choosing
1983 Modes}).
1984 @ifinfo
1985 nXML mode is described in its own manual: @xref{Top, nXML
1986 Mode,,nxml-mode, nXML Mode}.
1987 @end ifinfo
1988 @ifnotinfo
1989 nXML mode is described in an Info manual, which is distributed with
1990 Emacs.
1991 @end ifnotinfo
1992
1993 @vindex sgml-xml-mode
1994 You may choose to use the less powerful SGML mode for editing XML,
1995 since XML is a strict subset of SGML@. To enable SGML mode in an
1996 existing buffer, type @kbd{M-x sgml-mode}. On enabling SGML mode,
1997 Emacs examines the buffer to determine whether it is XML; if so, it
1998 sets the variable @code{sgml-xml-mode} to a non-@code{nil} value.
1999 This causes SGML mode's tag insertion commands, described above, to
2000 always insert explicit closing tags as well.
2001
2002 @node Nroff Mode
2003 @section Nroff Mode
2004
2005 @cindex nroff
2006 @findex nroff-mode
2007 @vindex nroff-mode-hook
2008 Nroff mode, a major mode derived from Text mode, is
2009 specialized for editing nroff files (e.g., Unix man pages). Type
2010 @kbd{M-x nroff-mode} to enter this mode. Entering Nroff mode runs the
2011 hook @code{text-mode-hook}, then @code{nroff-mode-hook}
2012 (@pxref{Hooks}).
2013
2014 In Nroff mode, nroff command lines are treated as paragraph
2015 separators, pages are separated by @samp{.bp} commands, and comments
2016 start with backslash-doublequote. It also defines these commands:
2017
2018 @findex forward-text-line
2019 @findex backward-text-line
2020 @findex count-text-lines
2021 @kindex M-n @r{(Nroff mode)}
2022 @kindex M-p @r{(Nroff mode)}
2023 @kindex M-? @r{(Nroff mode)}
2024 @table @kbd
2025 @item M-n
2026 Move to the beginning of the next line that isn't an nroff command
2027 (@code{forward-text-line}). An argument is a repeat count.
2028 @item M-p
2029 Like @kbd{M-n} but move up (@code{backward-text-line}).
2030 @item M-?
2031 Displays in the echo area the number of text lines (lines that are not
2032 nroff commands) in the region (@code{count-text-lines}).
2033 @end table
2034
2035 @findex electric-nroff-mode
2036 Electric Nroff mode is a buffer-local minor mode that can be used
2037 with Nroff mode. To toggle this minor mode, type @kbd{M-x
2038 electric-nroff-mode} (@pxref{Minor Modes}). When the mode is on, each
2039 time you type @key{RET} to end a line containing an nroff command that
2040 opens a kind of grouping, the nroff command to close that grouping is
2041 automatically inserted on the following line.
2042
2043 If you use Outline minor mode with Nroff mode (@pxref{Outline
2044 Mode}), heading lines are lines of the form @samp{.H} followed by a
2045 number (the header level).
2046
2047 @node Enriched Text
2048 @section Enriched Text
2049 @cindex Enriched mode
2050 @cindex mode, Enriched
2051 @cindex enriched text
2052 @cindex WYSIWYG
2053 @cindex word processing
2054 @cindex text/enriched MIME format
2055
2056 Enriched mode is a minor mode for editing formatted text files in a
2057 WYSIWYG (What You See Is What You Get) fashion. When Enriched
2058 mode is enabled, you can apply various formatting properties to the
2059 text in the buffer, such as fonts and colors; upon saving the buffer,
2060 those properties are saved together with the text, using the MIME
2061 @samp{text/enriched} file format.
2062
2063 Enriched mode is typically used with Text mode (@pxref{Text Mode}).
2064 It is @emph{not} compatible with Font Lock mode, which is used by many
2065 major modes, including most programming language modes, for syntax
2066 highlighting (@pxref{Font Lock}). Unlike Enriched mode, Font Lock
2067 mode assigns text properties automatically, based on the current
2068 buffer contents; those properties are not saved to disk.
2069
2070 The file @file{enriched.txt} in Emacs's @code{data-directory}
2071 serves as an example of the features of Enriched mode.
2072
2073 @menu
2074 * Enriched Mode:: Entering and exiting Enriched mode.
2075 * Hard and Soft Newlines:: There are two different kinds of newlines.
2076 * Editing Format Info:: How to edit text properties.
2077 * Enriched Faces:: Bold, italic, underline, etc.
2078 * Enriched Indentation:: Changing the left and right margins.
2079 * Enriched Justification:: Centering, setting text flush with the
2080 left or right margin, etc.
2081 * Enriched Properties:: The ``special text properties'' submenu.
2082 @end menu
2083
2084 @node Enriched Mode
2085 @subsection Enriched Mode
2086
2087 Enriched mode is a buffer-local minor mode (@pxref{Minor Modes}).
2088 When you visit a file that has been saved in the @samp{text/enriched}
2089 format, Emacs automatically enables Enriched mode, and applies the
2090 formatting information in the file to the buffer text. When you save
2091 a buffer with Enriched mode enabled, it is saved using the
2092 @samp{text/enriched} format, including the formatting information.
2093
2094 @findex enriched-mode
2095 To create a new file of formatted text, visit the nonexistent file
2096 and type @kbd{M-x enriched-mode}. This command actually toggles
2097 Enriched mode. With a prefix argument, it enables Enriched mode if
2098 the argument is positive, and disables Enriched mode otherwise. If
2099 you disable Enriched mode, Emacs no longer saves the buffer using the
2100 @samp{text/enriched} format; any formatting properties that have been
2101 added to the buffer remain in the buffer, but they are not saved to
2102 disk.
2103
2104 @vindex enriched-translations
2105 Enriched mode does not save all Emacs text properties, only those
2106 specified in the variable @code{enriched-translations}. These include
2107 properties for fonts, colors, indentation, and justification.
2108
2109 @findex format-decode-buffer
2110 If you visit a file and Emacs fails to recognize that it is in the
2111 @samp{text/enriched} format, type @kbd{M-x format-decode-buffer}.
2112 This command prompts for a file format, and re-reads the file in that
2113 format. Specifying the @samp{text/enriched} format automatically
2114 enables Enriched mode.
2115
2116 To view a @samp{text/enriched} file in raw form (as plain text with
2117 markup tags rather than formatted text), use @kbd{M-x
2118 find-file-literally} (@pxref{Visiting}).
2119
2120 @xref{Format Conversion,, Format Conversion, elisp, the Emacs Lisp
2121 Reference Manual}, for details of how Emacs recognizes and converts
2122 file formats like @samp{text/enriched}. @xref{Text Properties,,,
2123 elisp, the Emacs Lisp Reference Manual}, for more information about
2124 text properties.
2125
2126 @node Hard and Soft Newlines
2127 @subsection Hard and Soft Newlines
2128 @cindex hard newline
2129 @cindex soft newline
2130 @cindex newlines, hard and soft
2131
2132 @cindex use-hard-newlines
2133 In Enriched mode, Emacs distinguishes between two different kinds of
2134 newlines, @dfn{hard} newlines and @dfn{soft} newlines. You can also
2135 enable or disable this feature in other buffers, by typing @kbd{M-x
2136 use-hard-newlines}.
2137
2138 Hard newlines are used to separate paragraphs, or anywhere there
2139 needs to be a line break regardless of how the text is filled; soft
2140 newlines are used for filling. The @key{RET} (@code{newline}) and
2141 @kbd{C-o} (@code{open-line}) commands insert hard newlines. The fill
2142 commands, including Auto Fill (@pxref{Auto Fill}), insert only soft
2143 newlines and delete only soft newlines, leaving hard newlines alone.
2144
2145 @c FIXME: I don't see 'unfilled' in that node. --xfq
2146 Thus, when editing with Enriched mode, you should not use @key{RET}
2147 or @kbd{C-o} to break lines in the middle of filled paragraphs. Use
2148 Auto Fill mode or explicit fill commands (@pxref{Fill Commands})
2149 instead. Use @key{RET} or @kbd{C-o} where line breaks should always
2150 remain, such as in tables and lists. For such lines, you may also
2151 want to set the justification style to @code{unfilled}
2152 (@pxref{Enriched Justification}).
2153
2154 @node Editing Format Info
2155 @subsection Editing Format Information
2156
2157 The easiest way to alter properties is with the @samp{Text
2158 Properties} menu. You can get to this menu from the @samp{Edit} menu
2159 in the menu bar (@pxref{Menu Bar}), or with @kbd{C-mouse-2}
2160 (@pxref{Menu Mouse Clicks}). Some of the commands in the @samp{Text
2161 Properties} menu are listed below (you can also invoke them with
2162 @kbd{M-x}):
2163
2164 @table @code
2165 @findex facemenu-remove-face-props
2166 @item Remove Face Properties
2167 Remove face properties from the region
2168 (@code{facemenu-remove-face-props}).
2169
2170 @findex facemenu-remove-all
2171 @item Remove Text Properties
2172 Remove all text properties from the region, including face properties
2173 (@code{facemenu-remove-all}).
2174
2175 @findex describe-text-properties
2176 @cindex text properties of characters
2177 @cindex overlays at character position
2178 @cindex widgets at buffer position
2179 @cindex buttons at buffer position
2180 @item Describe Properties
2181 List all text properties and other information about the character
2182 following point (@code{describe-text-properties}).
2183
2184 @item Display Faces
2185 Display a list of defined faces (@code{list-faces-display}).
2186 @xref{Faces}.
2187
2188 @item Display Colors
2189 Display a list of defined colors (@code{list-colors-display}).
2190 @xref{Colors}.
2191 @end table
2192
2193 @noindent
2194 The other menu entries are described in the following sections.
2195
2196 @node Enriched Faces
2197 @subsection Faces in Enriched Text
2198
2199 The following commands can be used to add or remove faces
2200 (@pxref{Faces}). Each applies to the text in the region if the mark
2201 is active, and to the next self-inserting character if the mark is
2202 inactive. With a prefix argument, each command applies to the next
2203 self-inserting character even if the region is active.
2204
2205 @table @kbd
2206 @kindex M-o d @r{(Enriched mode)}
2207 @findex facemenu-set-default
2208 @item M-o d
2209 Remove all @code{face} properties (@code{facemenu-set-default}).
2210
2211 @kindex M-o b @r{(Enriched mode)}
2212 @findex facemenu-set-bold
2213 @item M-o b
2214 Apply the @code{bold} face (@code{facemenu-set-bold}).
2215
2216 @kindex M-o i @r{(Enriched mode)}
2217 @findex facemenu-set-italic
2218 @item M-o i
2219 Apply the @code{italic} face (@code{facemenu-set-italic}).
2220
2221 @kindex M-o l @r{(Enriched mode)}
2222 @findex facemenu-set-bold-italic
2223 @item M-o l
2224 Apply the @code{bold-italic} face (@code{facemenu-set-bold-italic}).
2225
2226 @kindex M-o u @r{(Enriched mode)}
2227 @findex facemenu-set-underline
2228 @item M-o u
2229 Apply the @code{underline} face (@code{facemenu-set-underline}).
2230
2231 @kindex M-o o @r{(Enriched mode)}
2232 @findex facemenu-set-face
2233 @item M-o o @var{face} @key{RET}
2234 Apply the face @var{face} (@code{facemenu-set-face}).
2235
2236 @findex facemenu-set-foreground
2237 @item M-x facemenu-set-foreground
2238 Prompt for a color (@pxref{Colors}), and apply it as a foreground
2239 color.
2240
2241 @findex facemenu-set-background
2242 @item M-x facemenu-set-background
2243 Prompt for a color, and apply it as a background color.
2244 @end table
2245
2246 @noindent
2247 These command are also available via the Text Properties menu.
2248
2249 A self-inserting character normally inherits the face properties
2250 (and most other text properties) from the preceding character in the
2251 buffer. If you use one of the above commands to specify the face for
2252 the next self-inserting character, that character will not inherit the
2253 faces properties from the preceding character, but it will still
2254 inherit other text properties.
2255
2256 Enriched mode defines two additional faces: @code{excerpt} and
2257 @code{fixed}. These correspond to codes used in the text/enriched
2258 file format. The @code{excerpt} face is intended for quotations; by
2259 default, it appears the same as @code{italic}. The @code{fixed} face
2260 specifies fixed-width text; by default, it appears the same as
2261 @code{bold}.
2262
2263 @node Enriched Indentation
2264 @subsection Indentation in Enriched Text
2265
2266 In Enriched mode, you can specify different amounts of indentation
2267 for the right or left margin of a paragraph or a part of a paragraph.
2268 These margins also affect fill commands such as @kbd{M-q}
2269 (@pxref{Filling}).
2270
2271 The Indentation submenu of Text Properties offers commands
2272 for specifying indentation:
2273
2274 @table @code
2275 @kindex C-x TAB @r{(Enriched mode)}
2276 @findex increase-left-margin
2277 @item Indent More
2278 Indent the region by 4 columns (@code{increase-left-margin}). In
2279 Enriched mode, this command is also available on @kbd{C-x @key{TAB}}; if
2280 you supply a numeric argument, that says how many columns to add to the
2281 margin (a negative argument reduces the number of columns).
2282
2283 @item Indent Less
2284 Remove 4 columns of indentation from the region.
2285
2286 @item Indent Right More
2287 Make the text narrower by indenting 4 columns at the right margin.
2288
2289 @item Indent Right Less
2290 Remove 4 columns of indentation from the right margin.
2291 @end table
2292
2293 @vindex standard-indent
2294 The variable @code{standard-indent} specifies how many columns these
2295 commands should add to or subtract from the indentation. The default
2296 value is 4. The default right margin for Enriched mode is controlled
2297 by the variable @code{fill-column}, as usual.
2298
2299 @kindex C-c [ @r{(Enriched mode)}
2300 @kindex C-c ] @r{(Enriched mode)}
2301 @findex set-left-margin
2302 @findex set-right-margin
2303 You can also type @kbd{C-c [} (@code{set-left-margin}) and @kbd{C-c
2304 ]} (@code{set-right-margin}) to set the left and right margins. You
2305 can specify the margin width with a numeric argument; otherwise these
2306 commands prompt for a value via the minibuffer.
2307
2308 The fill prefix, if any, works in addition to the specified paragraph
2309 indentation: @kbd{C-x .} does not include the specified indentation's
2310 whitespace in the new value for the fill prefix, and the fill commands
2311 look for the fill prefix after the indentation on each line. @xref{Fill
2312 Prefix}.
2313
2314 @node Enriched Justification
2315 @subsection Justification in Enriched Text
2316 @cindex justification style
2317
2318 In Enriched mode, you can use the following commands to specify
2319 various @dfn{justification styles} for filling. These commands apply
2320 to the paragraph containing point, or, if the region is active, to all
2321 paragraphs overlapping the region.
2322
2323 @table @kbd
2324 @kindex M-j l @r{(Enriched mode)}
2325 @findex set-justification-left
2326 @item M-j l
2327 Align lines to the left margin (@code{set-justification-left}).
2328
2329 @kindex M-j r @r{(Enriched mode)}
2330 @findex set-justification-right
2331 @item M-j r
2332 Align lines to the right margin (@code{set-justification-right}).
2333
2334 @kindex M-j b @r{(Enriched mode)}
2335 @findex set-justification-full
2336 @item M-j b
2337 Align lines to both margins, inserting spaces in the middle of the
2338 line to achieve this (@code{set-justification-full}).
2339
2340 @kindex M-j c @r{(Enriched mode)}
2341 @kindex M-S @r{(Enriched mode)}
2342 @findex set-justification-center
2343 @item M-j c
2344 @itemx M-S
2345 Center lines between the margins (@code{set-justification-center}).
2346
2347 @kindex M-j u @r{(Enriched mode)}
2348 @findex set-justification-none
2349 @item M-j u
2350 Turn off filling entirely (@code{set-justification-none}). The fill
2351 commands do nothing on text with this setting. You can, however,
2352 still indent the left margin.
2353 @end table
2354
2355 @vindex default-justification
2356 You can also specify justification styles using the Justification
2357 submenu in the Text Properties menu. The default justification style
2358 is specified by the per-buffer variable @code{default-justification}.
2359 Its value should be one of the symbols @code{left}, @code{right},
2360 @code{full}, @code{center}, or @code{none}; their meanings correspond
2361 to the commands above.
2362
2363 @node Enriched Properties
2364 @subsection Setting Other Text Properties
2365
2366 The Special Properties submenu of Text Properties has entries for
2367 adding or removing three other text properties: @code{read-only},
2368 (which disallows alteration of the text), @code{invisible} (which
2369 hides text), and @code{intangible} (which disallows moving point
2370 within the text). The @samp{Remove Special} menu item removes all of
2371 these special properties from the text in the region.
2372
2373 The @code{invisible} and @code{intangible} properties are not saved.
2374
2375 @node Text Based Tables
2376 @section Editing Text-based Tables
2377 @cindex table mode
2378 @cindex text-based tables
2379
2380 The @code{table} package provides commands to easily edit text-based
2381 tables. Here is an example of what such a table looks like:
2382
2383 @smallexample
2384 @group
2385 +-----------------+--------------------------------+-----------------+
2386 | Command | Description | Key Binding |
2387 +-----------------+--------------------------------+-----------------+
2388 | forward-char |Move point right N characters | C-f |
2389 | |(left if N is negative). | |
2390 | | | |
2391 +-----------------+--------------------------------+-----------------+
2392 | backward-char |Move point left N characters | C-b |
2393 | |(right if N is negative). | |
2394 | | | |
2395 +-----------------+--------------------------------+-----------------+
2396 @end group
2397 @end smallexample
2398
2399 When Emacs recognizes such a stretch of text as a table
2400 (@pxref{Table Recognition}), editing the contents of each table cell
2401 will automatically resize the table, whenever the contents become too
2402 large to fit in the cell. You can use the commands defined in the
2403 following sections for navigating and editing the table layout.
2404
2405 @findex table-fixed-width-mode
2406 Type @kbd{M-x table-fixed-width-mode} to toggle the automatic table
2407 resizing feature.
2408
2409 @menu
2410 * Table Definition:: What is a text based table.
2411 * Table Creation:: How to create a table.
2412 * Table Recognition:: How to activate and deactivate tables.
2413 * Cell Commands:: Cell-oriented commands in a table.
2414 * Cell Justification:: Justifying cell contents.
2415 * Table Rows and Columns:: Inserting and deleting rows and columns.
2416 * Table Conversion:: Converting between plain text and tables.
2417 * Table Misc:: Table miscellany.
2418 @end menu
2419
2420 @node Table Definition
2421 @subsection What is a Text-based Table?
2422 @cindex cells, for text-based tables
2423
2424 A @dfn{table} consists of a rectangular text area which is divided
2425 into @dfn{cells}. Each cell must be at least one character wide and
2426 one character high, not counting its border lines. A cell can be
2427 subdivided into more cells, but they cannot overlap.
2428
2429 Cell border lines are drawn with three special characters, specified
2430 by the following variables:
2431
2432 @table @code
2433 @vindex table-cell-vertical-char
2434 @item table-cell-vertical-char
2435 The character used for vertical lines. The default is @samp{|}.
2436
2437 @vindex table-cell-horizontal-chars
2438 @item table-cell-horizontal-chars
2439 The characters used for horizontal lines. The default is @samp{"-="}.
2440
2441 @vindex table-cell-intersection-char
2442 @item table-cell-intersection-char
2443 The character used for the intersection of horizontal and vertical
2444 lines. The default is @samp{+}.
2445 @end table
2446
2447 @noindent
2448 The following are examples of @emph{invalid} tables:
2449
2450 @example
2451 +-----+ +--+ +-++--+
2452 | | | | | || |
2453 | | | | | || |
2454 +--+ | +--+--+ +-++--+
2455 | | | | | | +-++--+
2456 | | | | | | | || |
2457 +--+--+ +--+--+ +-++--+
2458 a b c
2459 @end example
2460
2461 @noindent
2462 From left to right:
2463
2464 @enumerate a
2465 @item
2466 Overlapped cells or non-rectangular cells are not allowed.
2467 @item
2468 The border must be rectangular.
2469 @item
2470 Cells must have a minimum width/height of one character.
2471 @end enumerate
2472
2473 @node Table Creation
2474 @subsection Creating a Table
2475 @cindex create a text-based table
2476 @cindex table creation
2477
2478 @findex table-insert
2479 To create a text-based table from scratch, type @kbd{M-x
2480 table-insert}. This command prompts for the number of table columns,
2481 the number of table rows, cell width and cell height. The cell width
2482 and cell height do not include the cell borders; each can be specified
2483 as a single integer (which means each cell is given the same
2484 width/height), or as a sequence of integers separated by spaces or
2485 commas (which specify the width/height of the individual table
2486 columns/rows, counting from left to right for table columns and from
2487 top to bottom for table rows). The specified table is then inserted
2488 at point.
2489
2490 The table inserted by @kbd{M-x table-insert} contains special text
2491 properties, which tell Emacs to treat it specially as a text-based
2492 table. If you save the buffer to a file and visit it again later,
2493 those properties are lost, and the table appears to Emacs as an
2494 ordinary piece of text. See the next section, for how to convert it
2495 back into a table.
2496
2497 @node Table Recognition
2498 @subsection Table Recognition
2499 @cindex table recognition
2500
2501 @findex table-recognize
2502 @findex table-unrecognize
2503 Existing text-based tables in a buffer, which lack the special text
2504 properties applied by @kbd{M-x table-insert}, are not treated
2505 specially as tables. To apply those text properties, type @kbd{M-x
2506 table-recognize}. This command scans the current buffer,
2507 @dfn{recognizes} valid table cells, and applies the relevant text
2508 properties. Conversely, type @kbd{M-x table-unrecognize} to
2509 @dfn{unrecognize} all tables in the current buffer, removing the
2510 special text properties and converting tables back to plain text.
2511
2512 You can also use the following commands to selectively recognize or
2513 unrecognize tables:
2514
2515 @table @kbd
2516 @findex table-recognize-region
2517 @item M-x table-recognize-region
2518 Recognize tables within the current region.
2519
2520 @findex table-unrecognize-region
2521 @item M-x table-unrecognize-region
2522 Unrecognize tables within the current region.
2523
2524 @findex table-recognize-table
2525 @item M-x table-recognize-table
2526 Recognize the table at point and activate it.
2527
2528 @findex table-unrecognize-table
2529 @item M-x table-unrecognize-table
2530 Deactivate the table at point.
2531
2532 @findex table-recognize-cell
2533 @item M-x table-recognize-cell
2534 Recognize the cell at point and activate it.
2535
2536 @findex table-unrecognize-cell
2537 @item M-x table-unrecognize-cell
2538 Deactivate the cell at point.
2539 @end table
2540
2541 @xref{Table Conversion}, for another way to recognize a table.
2542
2543 @node Cell Commands
2544 @subsection Commands for Table Cells
2545
2546 @findex table-forward-cell
2547 @findex table-backward-cell
2548 The commands @kbd{M-x table-forward-cell} and @kbd{M-x
2549 table-backward-cell} move point from the current cell to an adjacent
2550 cell. The order is cyclic: when point is in the last cell of a table,
2551 @kbd{M-x table-forward-cell} moves to the first cell. Likewise, when
2552 point is on the first cell, @kbd{M-x table-backward-cell} moves to the
2553 last cell.
2554
2555 @findex table-span-cell
2556 @kbd{M-x table-span-cell} prompts for a direction---right, left,
2557 above, or below---and merges the current cell with the adjacent cell
2558 in that direction. This command signals an error if the merge would
2559 result in an illegitimate cell layout.
2560
2561 @findex table-split-cell
2562 @findex table-split-cell-vertically
2563 @findex table-split-cell-horizontally
2564 @cindex text-based tables, splitting cells
2565 @cindex splitting table cells
2566 @kbd{M-x table-split-cell} splits the current cell vertically or
2567 horizontally, prompting for the direction with the minibuffer. To
2568 split in a specific direction, use @kbd{M-x
2569 table-split-cell-vertically} and @kbd{M-x
2570 table-split-cell-horizontally}. When splitting vertically, the old
2571 cell contents are automatically split between the two new cells. When
2572 splitting horizontally, you are prompted for how to divide the cell
2573 contents, if the cell is non-empty; the options are @samp{split}
2574 (divide the contents at point), @samp{left} (put all the contents in
2575 the left cell), and @samp{right} (put all the contents in the right
2576 cell).
2577
2578 The following commands enlarge or shrink a cell. By default, they
2579 resize by one row or column; if a numeric argument is supplied, that
2580 specifies the number of rows or columns to resize by.
2581
2582 @table @kbd
2583 @findex table-heighten-cell
2584 @item M-x table-heighten-cell
2585 Enlarge the current cell vertically.
2586
2587 @findex table-shorten-cell
2588 @item M-x table-shorten-cell
2589 Shrink the current cell vertically.
2590
2591 @findex table-widen-cell
2592 @item M-x table-widen-cell
2593 Enlarge the current cell horizontally.
2594
2595 @findex table-narrow-cell
2596 @item M-x table-narrow-cell
2597 Shrink the current cell horizontally.
2598 @end table
2599
2600 @node Cell Justification
2601 @subsection Cell Justification
2602 @cindex justification in text-based tables
2603
2604 The command @kbd{M-x table-justify} imposes @dfn{justification} on
2605 one or more cells in a text-based table. Justification determines how
2606 the text in the cell is aligned, relative to the edges of the cell.
2607 Each cell in a table can be separately justified.
2608
2609 @findex table-justify
2610 @kbd{M-x table-justify} first prompts for what to justify; the
2611 options are @samp{cell} (just the current cell), @samp{column} (all
2612 cells in the current table column) and @samp{row} (all cells in the
2613 current table row). The command then prompts for the justification
2614 style; the options are @code{left}, @code{center}, @code{right},
2615 @code{top}, @code{middle}, @code{bottom}, or @code{none} (meaning no
2616 vertical justification).
2617
2618 Horizontal and vertical justification styles are specified
2619 independently, and both types can be in effect simultaneously; for
2620 instance, you can call @kbd{M-x table-justify} twice, once to specify
2621 @code{right} justification and once to specify @code{bottom}
2622 justification, to align the contents of a cell to the bottom right.
2623
2624 @vindex table-detect-cell-alignment
2625 The justification style is stored in the buffer as a text property,
2626 and is lost when you kill the buffer or exit Emacs. However, the
2627 table recognition commands, such as @kbd{M-x table-recognize}
2628 (@pxref{Table Recognition}), attempt to determine and re-apply each
2629 cell's justification style, by examining its contents. To disable
2630 this feature, change the variable @code{table-detect-cell-alignment}
2631 to @code{nil}.
2632
2633 @node Table Rows and Columns
2634 @subsection Table Rows and Columns
2635 @cindex inserting rows and columns in text-based tables
2636
2637 @findex table-insert-row
2638 @kbd{M-x table-insert-row} inserts a row of cells before the current
2639 table row. The current row, together with point, is pushed down past
2640 the new row. To insert a row after the last row at the bottom of a
2641 table, invoke this command with point below the table, just below the
2642 bottom edge. You can insert more than one row at a time by using a
2643 numeric prefix argument.
2644
2645 @c A numeric prefix argument specifies the number of rows to insert.
2646
2647 @findex table-insert-column
2648 Similarly, @kbd{M-x table-insert-column} inserts a column of cells
2649 to the left of the current table column. To insert a column to the
2650 right side of the rightmost column, invoke this command with point to
2651 the right of the rightmost column, outside the table. A numeric
2652 prefix argument specifies the number of columns to insert.
2653
2654 @cindex deleting rows and column in text-based tables
2655 @kbd{M-x table-delete-column} deletes the column of cells at point.
2656 Similarly, @kbd{M-x table-delete-row} deletes the row of cells at
2657 point. A numeric prefix argument to either command specifies the
2658 number of columns or rows to delete.
2659
2660 @node Table Conversion
2661 @subsection Converting Between Plain Text and Tables
2662 @cindex text to table
2663 @cindex table to text
2664
2665 @findex table-capture
2666 The command @kbd{M-x table-capture} captures plain text in a region
2667 and turns it into a table. Unlike @kbd{M-x table-recognize}
2668 (@pxref{Table Recognition}), the original text does not need to have a
2669 table appearance; it only needs to have a logical table-like
2670 structure.
2671
2672 For example, suppose we have the following numbers, which are
2673 divided into three lines and separated horizontally by commas:
2674
2675 @example
2676 1, 2, 3, 4
2677 5, 6, 7, 8
2678 , 9, 10
2679 @end example
2680
2681 @noindent
2682 Invoking @kbd{M-x table-capture} on that text produces this table:
2683
2684 @example
2685 +-----+-----+-----+-----+
2686 |1 |2 |3 |4 |
2687 +-----+-----+-----+-----+
2688 |5 |6 |7 |8 |
2689 +-----+-----+-----+-----+
2690 | |9 |10 | |
2691 +-----+-----+-----+-----+
2692 @end example
2693
2694 @findex table-release
2695 @kbd{M-x table-release} does the opposite: it converts a table back
2696 to plain text, removing its cell borders.
2697
2698 One application of this pair of commands is to edit a text in
2699 layout. Look at the following three paragraphs (the latter two are
2700 indented with header lines):
2701
2702 @example
2703 table-capture is a powerful command.
2704 Here are some things it can do:
2705
2706 Parse Cell Items Using row and column delimiter regexps,
2707 it parses the specified text area and
2708 extracts cell items into a table.
2709 @end example
2710
2711 @noindent
2712 Applying @code{table-capture} to a region containing the above text,
2713 with empty strings for the column and row delimiter regexps, creates a
2714 table with a single cell like the following one.
2715
2716 @smallexample
2717 @group
2718 +----------------------------------------------------------+
2719 |table-capture is a powerful command. |
2720 |Here are some things it can do: |
2721 | |
2722 |Parse Cell Items Using row and column delimiter regexps,|
2723 | it parses the specified text area and |
2724 | extracts cell items into a table. |
2725 +----------------------------------------------------------+
2726 @end group
2727 @end smallexample
2728
2729 @noindent
2730 We can then use the cell splitting commands (@pxref{Cell Commands}) to
2731 subdivide the table so that each paragraph occupies a cell:
2732
2733 @smallexample
2734 +----------------------------------------------------------+
2735 |table-capture is a powerful command. |
2736 |Here are some things it can do: |
2737 +-----------------+----------------------------------------+
2738 |Parse Cell Items | Using row and column delimiter regexps,|
2739 | | it parses the specified text area and |
2740 | | extracts cell items into a table. |
2741 +-----------------+----------------------------------------+
2742 @end smallexample
2743
2744 @noindent
2745 Each cell can now be edited independently without affecting the layout
2746 of other cells. When finished, we can invoke @kbd{M-x table-release}
2747 to convert the table back to plain text.
2748
2749 @node Table Misc
2750 @subsection Table Miscellany
2751
2752 @cindex table dimensions
2753 @findex table-query-dimension
2754 The command @code{table-query-dimension} reports the layout of the
2755 table and table cell at point. Here is an example of its output:
2756
2757 @smallexample
2758 Cell: (21w, 6h), Table: (67w, 16h), Dim: (2c, 3r), Total Cells: 5
2759 @end smallexample
2760
2761 @noindent
2762 This indicates that the current cell is 21 characters wide and 6 lines
2763 high, the table is 67 characters wide and 16 lines high with 2 columns
2764 and 3 rows, and a total of 5 cells.
2765
2766 @findex table-insert-sequence
2767 @kbd{M-x table-insert-sequence} inserts a string into each cell.
2768 Each string is a part of a sequence i.e., a series of increasing
2769 integer numbers.
2770
2771 @cindex table for HTML and LaTeX
2772 @findex table-generate-source
2773 @kbd{M-x table-generate-source} generates a table formatted for a
2774 specific markup language. It asks for a language (which must be one
2775 of @code{html}, @code{latex}, or @code{cals}), a destination buffer in
2776 which to put the result, and a table caption, and then inserts the
2777 generated table into the specified buffer. The default destination
2778 buffer is @code{table.@var{lang}}, where @var{lang} is the language
2779 you specified.
2780
2781 @node Two-Column
2782 @section Two-Column Editing
2783 @cindex two-column editing
2784 @cindex splitting columns
2785 @cindex columns, splitting
2786
2787 Two-column mode lets you conveniently edit two side-by-side columns
2788 of text. It uses two side-by-side windows, each showing its own
2789 buffer. There are three ways to enter two-column mode:
2790
2791 @table @asis
2792 @item @kbd{@key{F2} 2} or @kbd{C-x 6 2}
2793 @kindex F2 2
2794 @kindex C-x 6 2
2795 @findex 2C-two-columns
2796 Enter two-column mode with the current buffer on the left, and on the
2797 right, a buffer whose name is based on the current buffer's name
2798 (@code{2C-two-columns}). If the right-hand buffer doesn't already
2799 exist, it starts out empty; the current buffer's contents are not
2800 changed.
2801
2802 This command is appropriate when the current buffer is empty or contains
2803 just one column and you want to add another column.
2804
2805 @item @kbd{@key{F2} s} or @kbd{C-x 6 s}
2806 @kindex F2 s
2807 @kindex C-x 6 s
2808 @findex 2C-split
2809 Split the current buffer, which contains two-column text, into two
2810 buffers, and display them side by side (@code{2C-split}). The current
2811 buffer becomes the left-hand buffer, but the text in the right-hand
2812 column is moved into the right-hand buffer. The current column
2813 specifies the split point. Splitting starts with the current line and
2814 continues to the end of the buffer.
2815
2816 This command is appropriate when you have a buffer that already contains
2817 two-column text, and you wish to separate the columns temporarily.
2818
2819 @item @kbd{@key{F2} b @var{buffer} @key{RET}}
2820 @itemx @kbd{C-x 6 b @var{buffer} @key{RET}}
2821 @kindex F2 b
2822 @kindex C-x 6 b
2823 @findex 2C-associate-buffer
2824 Enter two-column mode using the current buffer as the left-hand buffer,
2825 and using buffer @var{buffer} as the right-hand buffer
2826 (@code{2C-associate-buffer}).
2827 @end table
2828
2829 @kbd{@key{F2} s} or @kbd{C-x 6 s} looks for a column separator, which
2830 is a string that appears on each line between the two columns. You can
2831 specify the width of the separator with a numeric argument to
2832 @kbd{@key{F2} s}; that many characters, before point, constitute the
2833 separator string. By default, the width is 1, so the column separator
2834 is the character before point.
2835
2836 When a line has the separator at the proper place, @kbd{@key{F2} s}
2837 puts the text after the separator into the right-hand buffer, and
2838 deletes the separator. Lines that don't have the column separator at
2839 the proper place remain unsplit; they stay in the left-hand buffer, and
2840 the right-hand buffer gets an empty line to correspond. (This is the
2841 way to write a line that spans both columns while in two-column
2842 mode: write it in the left-hand buffer, and put an empty line in the
2843 right-hand buffer.)
2844
2845 @kindex F2 RET
2846 @kindex C-x 6 RET
2847 @findex 2C-newline
2848 The command @kbd{C-x 6 @key{RET}} or @kbd{@key{F2} @key{RET}}
2849 (@code{2C-newline}) inserts a newline in each of the two buffers at
2850 corresponding positions. This is the easiest way to add a new line to
2851 the two-column text while editing it in split buffers.
2852
2853 @kindex F2 1
2854 @kindex C-x 6 1
2855 @findex 2C-merge
2856 When you have edited both buffers as you wish, merge them with
2857 @kbd{@key{F2} 1} or @kbd{C-x 6 1} (@code{2C-merge}). This copies the
2858 text from the right-hand buffer as a second column in the other buffer.
2859 To go back to two-column editing, use @kbd{@key{F2} s}.
2860
2861 @kindex F2 d
2862 @kindex C-x 6 d
2863 @findex 2C-dissociate
2864 Use @kbd{@key{F2} d} or @kbd{C-x 6 d} to dissociate the two buffers,
2865 leaving each as it stands (@code{2C-dissociate}). If the other buffer,
2866 the one not current when you type @kbd{@key{F2} d}, is empty,
2867 @kbd{@key{F2} d} kills it.