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