Chapter 7. Simple Text Formatting and Specialized Editing

Emacs is fundamentally a text editor, rather than a word processor: it is a tool that creates files containing exactly what you see on the screen rather than a tool that makes text files look beautiful when printed. However, Emacs does give you the capability to do the following:

• Indent text using tabs and other indentation tricks.

• Center words, lines, and paragraphs of text.

• Hide and show portions of a document using outline mode, which gives you a feel for a document's overall structure. Outline mode can make it easier to go from rough outline, to detailed outline, to rough draft, to the final product.

• Edit by column rather than by line (especially helpful when you create or change tables or work with column-oriented datasets), referred to in Emacs as rectangle editing.

• Create simple pictures using keyboard characters or the mouse.

Much of this chapter, though, focuses on some fairly simple stuff: tabs and indenting text. We describe Emacs's behavior in primarily two major modes: fundamental mode and text mode. If you are a developer, you'll probably want to write code in a mode appropriate to the language you're using; see Chapter 9 for details. If you use a markup language like HTML, see Chapter 8 for additional relevant information.

7.1 Using Tabs

Tabs provide an easy way to do some simple formatting. While we were revising this book, we found that the way Emacs handles tabs has changed a great deal. This section describes first how Emacs works by default and then discusses what you can do to change the default behavior to meet your needs.

7.1.1 How Emacs 21 Handles Tabs by Default

If you open a new file in text mode, tabs are set every eight spaces by default. (Programming modes have their own indentation behavior; see Chapter 9 for details.)


Press Tab.

Pressing Tab in text mode or fundamental mode inserts a tab character that moves the cursor forward eight columns by default.


Watch what happens when we type a sentence. The default tab stops change automatically.


Type: It was the best of times Enter Tab Tab

Pressing Tab twice moves the cursor under the word was, clearly less than eight columns.


Every time you press Tab, Emacs moves the cursor under the next word. This is the behavior that many people expect when writing code. Neatly lined up code is easier to read.

As we experimented with this feature, we would tab across under each word, and press Enter. What happens next is surprising if you are not expecting it. Emacs considers that newline to be the only character you typed on the line, so pressing Tab on a subsequent line brings you nearly to the end of the line.


Press Tab repeatedly to the end of the window, press Enter, then press Tab once.

Emacs moves the cursor to the column where you pressed Enter.


If you press Enter but don't press Tab at all, the indentation level moves back to the left margin.

Changing tabs to align with each word can be helpful, if, for example, you're typing tables. However, the default tab behavior may not be helpful to you in all situations. If you are interested in changing the default behavior, read on and we'll describe how to get Emacs to do what you want it to do.

7.1.2 Changing Tab Stops

By default (and if text is not lining up with some previous line of text), tabs are set every eight characters. Emacs allows you to change the positions of the tab stops. To change the tab stops, type M-x edit-tab-stops. A

*Tab Stops*
buffer appears.


Type: M-x edit-tab-stops

You now see a tab stop ruler; colons show the locations of tab stops.


The colons in the first line of the display show you where tab stops are currently located. The next two lines form a ruler that shows each character position on the line. To insert a tab, use C-f to move to the desired column, and then type a colon (:). To delete a tab, move to the desired tab, and press Space. The

*Tab Stops*
buffer is in overwrite mode, so these changes won't change the position of other tabs. Make sure that you do all your editing in the first line of the display. Changes made to the other lines won't have any effect.

When you're satisfied with the tab stops, press C-c C-c to install them. If you don't make any changes, press C-c C-c to exit the buffer. If you make some changes and then decide you don't want them after all, kill the buffer by typing C-x k Enter. The default tab stops remain in effect.

If you press C-c C-c to install them, the new tab settings affect all buffers that you create but remain in effect for this Emacs session only.

Again, it may well appear to you that this feature doesn't work as you would expect. Because Emacs's default behavior tries to align with preceding lines, changing tab stops really affects only the first line of any buffer.

In this example, we set the first tab at column 51, pressed C-c C-c to install the tab stops, and started a new buffer. Pressing Tab at the beginning of the buffer moves the cursor immediately to column 51. That works fine.


Press Tab once.

Cursor moves to column 51.


Now we press Tab a few more times, followed by Enter to move to a new line.

When we press Tab on the second line, Emacs views the newline as the only item on the last line. Pressing Tab moves us right to the end of the line.


Press Tab on the next line.

Emacs moves to the end of the line.


As you can see, changing tab stops in this way is of limited efficacy if you're going to add blank lines between rows of your table or whatever you're typing. You'd have to work around this by adding blank lines after typing the whole table, perhaps using a macro as described in Chapter 6.

7.1.3 What if You Want Literal Tabs?

Let's say that all this tab finery is getting on your nerves. You don't want context-sensitive indenting; you don't even want to change tab stops. There is a way to make Emacs treat tabs just like a regular old typewriter did, moving over eight characters at a time.[35]

To insert rigid, typewriter-style tabs, press C-q Tab. In theory, this should insert a tab character into the file, which would look like ^I. In practice, it moves the cursor forward rigidly eight columns.


Type: C-q Tab

The cursor moves eight columns forward and does not align with the text in the previous line.


C-q Tab does in fact insert a tab character in the file. You can check that by erasing it with a single press of the Del key.

7.1.4 Changing Tab Width

One problem with tabs is that there is no universal definition of what a tab means. In vi, the default tab width is four columns versus eight columns in Emacs. Further, Unix generally favors eight columns for tabs while some operating systems tend to use four spaces. Emacs uses eight columns by default no matter what platform it's running on. If you view another user's file in Emacs, Emacs interprets the tabs as eight columns each, throwing things off. For this reason, you might want to set your tab default to four columns by adding this line to your .emacs file:

(setq-default tab-width 4)

You have to press C-q Tab to have the modified tab width take effect.

7.1.5 Tabs and Spaces

Another characteristic of Emacs's default behavior is the fact that it may insert a combination of tabs and spaces when you press Tab. Try to erase a few "tabs" and you'll see that often it isn't one character, but the equivalent number of spaces or a combination of tabs and spaces. Of course, this largely depends on the tab stops compared to setting of the

tab-width
variable. If you set tab stops that are multiples of six while you have a
tab-width
of 4 or 8, Emacs is going to have to use a combination of tabs and spaces to achieve the desired tab stops.

If you want Emacs to insert spaces for indentation rather than tab characters, add this line to your .emacs file:

(setq-default indent-tabs-mode nil)

With this setting, Emacs inserts only spaces when you press Tab. Pressing C-q Tab instead inserts a literal tab character. It's safe to say you won't enter tab characters accidentally with this setting.

7.1.6 Changing Tabs to Spaces (and Vice Versa)

We've just talked about a way to make sure that Emacs inserts spaces instead of tabs. But what if you inherit a file and it has tabs that you want to change to spaces?

Emacs provides a command to banish tabs from your files. You can use tabs for editing and then convert all of the tabs to the appropriate number of spaces so that the appearance of your file doesn't change. Unlike tabs, a space is almost always well defined. The command for eliminating tabs is M-x untabify. There's a corresponding command to convert spaces into tabs: tabify. However, we trust that you'll take our advice and forget about it.

The untabify command works on a region. Therefore, to use it, you must put the mark somewhere in the buffer (preferably at the beginning), move to some other place in the buffer (preferably the end), and type M-x untabify Enter. The command C-x h (for mark-whole-buffer) automatically puts the cursor at the beginning of the buffer and the mark at the end. It makes untabification a bit easier because you can do it all at once with the simple sequence C-x h M-x untabify Enter.

Table 7-1 shows the tab commands we've covered in this section.


Table 7-1. Tab commands

Keystrokes Command name Action
(none) edit-tab-stops Open a buffer called
*Tab Stops*
where you can change the tab settings.
(none) untabify Change all tabs into the equivalent number of spaces.
(none) tabify Change groups of three or more spaces to tabs where possible without affecting the text placement.

7.2 Indenting Text

Emacs provides the ability to indent paragraphs, like a block quote in a paper. It also allows you to use a paragraph style that indents just the first line of a paragraph. This section describes indentation-related commands, including how to change the margins for the current session.

Before we start, make sure you're in text mode. Look at the mode line and, if the word

Text
is displayed, you are in text mode. If not, type M-x text-mode Enter to enter text mode.

7.2.1 Indenting Paragraphs

Let's say you're writing a paper and want to include some indented block quotes. Emacs's default behavior makes this a no-brainer.[36] After you finish your first paragraph, use tabs or spaces to indent to the desired level and start typing the quote. Emacs automatically fills the paragraph and the quote correctly, as shown in the following screen.


Some indented text:

Emacs indents the text properly and fills it correctly in auto-fill mode.


What if an indented quote has multiple paragraphs? You could just press Enter and then Tab again at the beginning of subsequent paragraphs or you could press C-j (for newline-and-indent). Pressing C-j twice gives you a blank line between paragraphs.

7.2.2 Indenting the First Line of a Paragraph

Some people prefer paragraphs in which the first line is indented. Knowing about the intricacies of tabs, you might be concerned that pressing Tab to indent the opening line of your paragraph will incite Emacs to indent the whole paragraph as you continue typing. And it would, to be honest.

Emacs provides a special mode for this purpose: paragraph indent text mode. It's also available as a minor mode. Enter either M-x paragraph-indent-text-mode or M-x paragraph-indent-minor-mode respectively. If you run the major mode, Emacs displays

Parindent
on the mode line.

When you press Tab to start a paragraph, Emacs inserts a tab's worth of space. When you start a new paragraph, you don't have to skip a line in between and pressing Tab to start that second paragraph yields again a tab's worth of space, not aligning with the second word of the previous line as Emacs would do in text mode or fundamental mode.

Pressing M-q reformats paragraphs without mushing them all together. If you prefer indented paragraphs, this mode is exactly what you want. When you need to indent a block quote, you may want to temporarily enter text mode to make it easier and add your paragraph indentations manually.

7.2.3 Filling Indented Paragraphs

Let's say you've got a paper with paragraphs indented at various levels. What if you edit them and need to fill them again? Especially if there are no blank lines in between paragraphs, M-q munges all the text into one big (nonindented) paragraph. Instead of M-q, mark the region in question and use a special fill command: M-x fill-individual-paragraphs. Emacs preserves each paragraph's indentation.

Let's contrast these two commands with an example. We'll use our previous Henry James example, but delete the lines between paragraphs to show what happens if you use M-q in this case. These paragraphs need to be reformatted.


Initial state:

Some sample paragraphs from Henry James, in need of reformatting.


Type: M-q

Emacs munges it all into one large paragraph.


We'll undo that command, mark the buffer as a region, and use the fill-individual-paragraphs command.


Type: C- _ C-x h M-x fill-individual-paragraphs Enter

Emacs refills the paragraphs properly.

7.2.3.1 Indenting regions

What if you have already typed your text without indentation and want to indent it later? Two commands can handle this, depending on how far you want to indent the region.

The indent-region command, bound to C-M-\, can indent a region one level easily. If you want to indent two levels, it is unpredictable. (This command is designed for indenting code.)

Here's an example. The second paragraph is marked as a region.


Type: C-M-\

Emacs indents the paragraph one level.


You decide that's not far enough.


Type: C-M-\

Emacs creates a stairstep hanging indent.


So you can see that this works fine if you're indenting one level. If you try this with multiple paragraphs of different indentation levels, indent-region pulls them all to the right, aligning them with the least indented paragraph, probably not what you intended. If you write code, however, this command is great for cleaning up messy indentation.

The other option is to mark the region and type C-x Tab (for indent-rigidly). By default, this command indents only one space, so if you want to indent further, you need to give it an argument. For example, to indent the previous paragraph 15 spaces:


Mark the region then type: M-15 C-x Tab

Emacs indents the paragraph 15 spaces.


Although arguably it can be a pain to supply an argument, indent-rigidly uniformly indents text, leaving indented paragraphs indented. If you find yourself wanting to indent whole files, you may actually want to change the margin settings, as described in the next section.

7.2.3.2 Other indentation tricks

Whenever you are using indentation, you can use M-m (for back-to-indentation) to move to the first nonblank character on a line. On a line that's not indented, this command simply moves you to the beginning of the line. In other words, M-m brings you to the "logical" beginning of the line, which is what you usually mean when you type C-a.

Another indentation command is C-M-o (for split-line). You can use this command to create a stairstep effect. Move the cursor to the text that you want to put on the next line and press C-M-o. Note that there must be some text following the cursor in order for this command to work properly; if you try it at the end of a line, it does nothing.


Initial state:

We want to split this line.


Type: C-M-o

C-M-o splits the line at the cursor position.

7.2.4 Changing Margins

Emacs is not a word processor, but it does have a few commands that change left and right indentation for a buffer for the current session. First, mark the whole buffer using C-x h. You can then gchange the indention using M-x followed by one of the following commands:

increase-left-margin

decrease-left-margin

increase-right-margin

decrease-right-margin

These commands are also available through the Edit menu. Choose Edit → Text Properties → Indentation to see the options.

Unless you supply a numeric argument using C-u or M-n preceding these commands, Emacs increases or decreases the margins by the number of characters in the variable standard-indent, which defaults to 4. If auto-fill mode is on, Emacs also reformats the paragraphs automatically.

Margin settings remain in effect for the current session and the current buffer only. Although the values don't persist to another session, any text that is indented using this method remains indented when you reopen the file. If you open the file again and add some text, however, it is not indented; you have to set the margins again.

These commands work best in cases where you want to change the margin for the whole buffer. If you define a smaller region, the commands work but if you type more paragraphs, the margin settings persist whether you want them to or not. These commands work fine if you've completed the file and then decide to change the indentation.

Alternatively, you can set and save margins using enriched mode, a minor mode that allows Emacs to save text properties, including margin settings and font changes. See Chapter 10 for more details on enriched mode.

7.2.5 Using Fill Prefixes

Fill prefixes are a way of putting a certain string of characters at the beginning of each line in a paragraph or a file. Developers will immediately think of comments as a potential fill prefix. When writing email or newsposts, email programs often insert a string to help readers distinguish the threads of a discussion. For those of us writing text files, fill prefixes can be used to insert whitespace in paragraphs or any relevant string of characters.

The term fill prefix comes from the fact that Emacs calls word wrap auto-fill mode; in other words, a fill prefix is a string that Emacs should insert at the beginning of each line (or "prefix" each line with) when doing word wrap.

To use fill prefixes, it's best to be in auto-fill mode. If your mode line says

Fill
on it, you're already in auto-fill mode. If it doesn't, type M-x auto-fill-mode Enter.

Now let's assume that you want to indent a letter. For the first line of the letter, type your indentation by hand—say, eight spaces. Then type C-x . (for set-fill-prefix). Emacs displays the message:

fill prefix " "
in the minibuffer. Then start typing normally. Whenever you type past the right margin and Emacs breaks a line for you, it automatically inserts your eight-space indentation at the beginning of the line.

Here's a slightly more exciting example. There's no reason that fill prefixes must to be spaces; they can be anything you choose. Assume that you're sending an email message to your friends to announce a unique event and you want an eye-catching fill prefix.


Type: Elephant Riding Party!!! C-x .

Type the prefix, then C-x . to set it.


Once you've set the prefix, you can type your message normally.


Type: The time . . . the zoo.

Emacs inserts the fill prefix at the beginning of each line of the message.


You had to type "Elephant Riding Party!!!" only once; Emacs inserted the rest automatically. Here are some things you might want to know about fill prefixes:

• Emacs never applies the fill prefix to the first line of a paragraph. You obviously can't apply it to the first line of the first paragraph (you have to type it somewhere). But Emacs can't apply it to the first line of any paragraph. In other words, if the "elephant riding" message had two paragraphs, you'd have to type (or yank) the phrase "Elephant Riding Party!!!" at the beginning of the second paragraph.

• However, you don't need to set the fill prefix again. Emacs supplies your prefix for all lines but the first in subsequent paragraphs. It just gets confused about the initial line of any paragraph.

• Once you've started using a fill prefix, how do you turn it off? There's no special command. All you do is put the cursor at the left margin and type C-x . to define a new, empty fill prefix.

• You can edit paragraphs with fill prefixes, then reformat them with M-q, as long as the fill prefix is still defined. If you have cleared the fill prefix, Emacs reformats the paragraph without regard to the fill prefix. If you need to reformat your paragraphs later, after you've canceled the fill prefix, define it again and then type M-q.

Table 7-2 lists the indentation commands we've discussed.


Table 7-2. Indentation commands

Keystrokes Command name Action
C-j newline-and-indent Move to the next line and indent to the current level.
(none) paragraph-indent-text-mode A major mode for writing paragraphs with indented first lines and no blank lines between paragraphs.
(none) paragraph-indent-minor-mode The minor mode equivalent of paragraph-indent-text mode.
(none) fill-individual-paragraphs Reformat indented paragraphs, preserving indentation.
C-x Tab indent-rigidly Indent one column; preface with C-u or M-n to specify multiple columns.
C-M-\ indent-region Indent a region to match the first line in the region.
M-m back-to-indentation Move the cursor to the first non-whitespace character on a line.
C-M-o split-line Split the line at the cursor position and indent it to the column of the cursor position.
(none)EditText PropertiesIndentationIndent More increase-left-margin Increase the left indentation level for the buffer by four characters by default.
(none)EditText PropertiesIndentationIndent Less decrease-left-margin Decrease the left indentation level for the buffer by four characters by default.
(none)EditText PropertiesIndentationIndent Right More decrease-right-margin Decrease the right indentation level for the buffer by four characters by default.
(none)EditText PropertiesIndentationIndent Left More increase-right-margin Increase the right indentation level for the buffer by four characters by default.
C-x . set-fill-prefix Use the information up to the cursor column as a prefix to each line of the paragraph; typing this command in column 1 cancels the fill prefix.

7.3 Centering Text

Another common formatting task is centering text. For example, you might want to center the title of a document or individual headings within a document. Emacs provides commands to center lines, paragraphs, and regions.

In text mode, you can center a line by simply typing the line you want to center (or moving anywhere on an existing line), and then pressing M-s.


Type: Annual Report

You type the document's title.


Type: M-s

Emacs centers the line.


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


Type: M-S

Text is now centered.


In this case, line-by-line centering looks rather artistic. But there are times when you might wish Emacs did block centering. You can replicate this effect by using the indent-rigidly command, discussed earlier in this chapter. You just have to play with the indentation to see how far the block of text should be indented to look centered.

There's one more choice for centering. You can change justification by choosing Edit → Text Properties → Justification → Center. This command works on whatever text is selected.

Table 7-3 lists the commands used to center text.


Table 7-3. Centering commands

Keystrokes Command name Action
M-s center-line Center the line the cursor is on.
M-S center-paragraph Center the paragraph the cursor is on.
(none) center-region Center the currently defined region.
(none)EditText PropertiesJustificationCenter set-justification-center Center selected text.

7.4 Using Outline Mode

When you're writing something, whether it's a book, a long paper, or a technical specification, getting a sense of organization as you go along is frequently difficult. Without a sense of structure, it is hard to expand an outline smoothly into a longer paper or to reorganize a paper as you go along. The words get in the way of your headings, making it hard to see the forest for the trees.

Outline mode provides a built-in solution to this problem. This mode gives you the ability to hide or display text selectively, based on its relationship to the structure of your document. For example, you can hide all of your document's text except for its headings, thereby giving you a feel for the document's shape. When you're looking at the headings, you can focus on structure without being concerned about individual paragraphs. When you've solved your structural problems, you can make the text reappear.

Outline mode is more useful for documents with several levels of headings (or for long programs) than for plain outlines containing very little text. The longer a document is, the harder it is to get a quick feel for the overall structure; it is in such a situation that outline mode's ability to hide and show portions of the text comes in handy.

Outline mode requires you to follow some special conventions in your outline or document. Figure 7-1 shows an outline in traditional format and the same outline prepared for outline mode. On the left, we show a "traditional" outline; on the right, we show the same outline, after being prepared for outline mode:


Figure 7-1. Traditional Outline versus Outline Mode


Whereas traditional outlines use a hierarchical scheme of Roman numerals, uppercase letters, numbers, and lowercase letters for heading levels 1 through 4, outline mode by default expects to see one asterisk (*) for a first-level heading, two for a second-level heading, and so on. Lines that don't start with an *, such as "This book is all-inclusive," are referred to as body lines. Notice that Emacs expects to see the asterisk in the first column. You can use traditional outline indentation, provided that the asterisks start in the first column.[37]

The sample outline has only two body lines. As we developed the book, though, we'd gradually add more and more body: "This book is all-inclusive" would be replaced by a substantial chunk of the preface, and other body lines later in the outline would turn into the text for Chapter 1. When used properly, outline mode removes the distinction between outlining and writing. As your outline grows and becomes more detailed, it can gradually become your paper.

7.4.1 Entering Outline Mode

To start outline mode, type M-x outline-mode Enter.

Outline
appears on the mode line. (Outline mode is also available as a minor mode; we'll discuss that later in this section.)

After you are in outline mode, you can use special commands to move quickly from one part of the outline to another. C-c C-n moves to the next heading or subheading; C-c C-p moves to the previous one. C-c C-f moves to the next heading of the same level, so you can use this command to move from one first-level heading to another throughout the outline, or from one second-level heading to another within a given entry. C-c C-b moves backward to the previous heading of the same level. If you want to move from a second-level heading to its first-level heading, up a level in the outline structure, you type C-c C-u. (If you are on a first-level heading already, C-c C-u beeps because it can't move to a higher level.) Figure 7-2 illustrates how these cursor commands would work on our sample outline.


Figure 7-2. Moving around in outline mode


These commands make it easy to solve a lot of organizational problems. If you often think, "I know I'm writing about widgets, but I can't remember the bigger point I'm trying to make," type C-c C-u to get to the next higher level of the outline. If you want to figure out how widgets relate to the other topics within the section, use C-c C-b and C-c C-f to move backward and forward to your other headings.

7.4.2 Hiding and Showing Text

The most important feature of outline mode is the ability to selectively hide or show different portions of your text. The ability to see a skeletal view of a long document with outline mode is its best feature; it's much easier to evaluate the structure of a document when you can hide everything but the headings and see whether it is coherent or in need of some reorganization.

Although it sounds like something out of a detective novel, the hide-body command, C-c C-t, hides all the body (or text) lines but leaves all the headings (lines that begin with an asterisk) visible. Wherever Emacs hides text, it places an ellipsis (...) on the corresponding heading line. The ellipsis tells you that some hidden text is present. The buffer itself is not modified; you'll notice, if you watch the left side of the mode line, that the asterisks that indicate a modified buffer don't appear. If you save a file and exit while some text is hidden, Emacs saves the hidden text along with what you see displayed; hiding text in no way implies losing text. The next time you read the file, Emacs shows all text that was hidden.

Using the hide-body command is a good way to get a feel for the structure of a long document. You can then type C-c C-t and see only the headings without the text. For example, let's start with the simple outline we gave above and hide the body.


Type: C-c C-t

The body is hidden; ellipses show us where body lines are.


To show all the hidden text in a file, whether headings or body, type C-c C-a (for show-all). These commands, hide-body and show-all, work on the outline as a whole. A command similar to hide-body is hide-sublevels, C-c C-q. This command shows only first-level headers, giving you a feel for the major sections in the document you're working on.


Type: C-c C-q

Only first-level headers appear.

7.4.3 Editing While Text Is Hidden

Now that you know how to hide and show text, let's discuss some of the properties of hidden text. Editing a document while some of it is hidden is often useful—it's a great way to make major changes in document structure—but there are some dangers that you should be aware of. Let's say you've hidden all text with outline mode and only the headings are showing, giving you a true "outline" of your document. If you move a heading that has hidden text and headings associated with it, everything that is hidden moves when you move the visible text. Later, when you "show" all of the document, the hidden text appears in its new location—underneath the heading that you moved. Similarly, if you delete a heading, you delete all hidden text as well.

This feature makes moving blocks of text easy. However, there are some things to watch out for. If you delete the ellipsis following an entry, Emacs deletes the hidden information as well. To its credit, Emacs tries to keep you from doing this; it does not allow you to delete the ellipsis using the Del key or using normal cursor commands like C-b to move the cursor onto it. However, if you're persistent you can delete the ellipses (and the text it represents) using, for example, C-k. If you do so, Emacs deletes the hidden text. Typing C-y yanks the hidden text that you killed when you deleted the ellipsis; the undo command, C-_, restores the ellipsis. Our advice is to display text before deleting it so you can see what you're doing. On the other hand, when you are moving sections of an outline around, it is helpful to do so while text is hidden so you can keep the structure in mind.

Be careful when moving hidden text to a buffer that's not in outline mode. Let's say that your outline ends with a heading followed by an ellipsis. When marking that section to move to another buffer, make sure the region includes the newline following the ellipsis (for example, move to the beginning of the next line). If you simply place the cursor following the ellipsis, Emacs copies only the header, not the hidden text. We're not sure why. Moving past the newline copies the body as well as the heading correctly, and pasting it into a buffer in text mode shows all the hidden text.

7.4.4 Marking Sections of the Outline

When you're moving text around, it's convenient to be able to mark a section of the outline and then move it or promote or demote it a level, as we'll discuss next. To mark a section of the outline (the current heading and its children), type C-c @ (for outline-mark-subtree). You can then cut or paste the section you've marked. You might want to type C-x C-x to verify that the region is marked correctly.

7.4.5 Promoting and Demoting Sections

Often as you're writing, you find that a certain heading should really be promoted or demoted a level. To promote a heading, type C-c C-^. To demote it a level, C-c C-v. (Note the clever attempt to make the key bindings indicate that you're moving headings up or down a level using ^ and v.) This automatically changes the markings for the heading in question. In other words, promoting a second-level heading removes an asterisk, making it a first-level heading. You'll find the commands to move to the next and previous headings, C-c C-n and C-c C-p, helpful when you are promoting and demoting sections.

But what if you want to demote not just a heading but a subtree? Or even the entire outline? At the moment, you'd have to write a Lisp function to do that (or use someone else's). Several functions like this have been written by gurus and posted online, but none are part of Emacs at this writing. We hope this function is incorporated soon.

7.4.6 Using Outline Minor Mode

Outline mode is also available as a minor mode so that you can use it subordinately to your favorite major mode. To start outline mode as a minor mode, type M-x outline-minor-mode;

Outl
appears on the mode line. In some ways, this mode is less convenient; rather than the simple C-c prefix you use for most outline mode commands, in outline minor mode, you must preface all commands with C-c @ instead, to avoid interfering with the usual C-c commands of the major mode. So, if you want to move down to the next heading (the C-c C-n command in outline mode), you would type C-c @ C-n instead.

Please note that mixing outline major mode and outline minor mode is not only redundant but can be dangerous. Turning on the minor mode while the major mode is on can confuse Emacs. Exit outline mode, then enter outline minor mode if you wish.

Table 7-4 summarizes outline mode commands. In the next section, we discuss another specialized editing method: editing with rectangles.


Table 7-4. Outline mode commands

Keystrokes Command name Action
(none) outline-mode Toggle outline mode.
C-c C-n HeadingsNext outline-next-visible-heading Move to the next heading.
C-c C-p HeadingsPrevious outline-previous-visible-heading Move to the previous heading.
C-c C-f HeadingsNext Same Level outline-forward-same-level Move to the next heading of the same level.
C-c C-b HeadingsPrevious Same Level outline-backward-same-level Move to the previous heading of same level.
C-c C-u HeadingsUp outline-up-heading Move up one heading level.
C-c C-t HideHide Body hide-body Hide all body lines.
C-c C-a ShowShow All show-all Show everything that's hidden.
C-c C-q HideHide Sublevels hide-sublevels Display first level headers only.
C-c C-o HideHide Other hide-other Hide all text and headings outside the current subtree. First level headers show.
C-c @ outline-mark-subtree Mark the current header and all sublevels.
C-c C-^ outline-promote Promote the current heading one level.
C-c C-v outline-demote Demote the current heading one level.
C-c C-d HideHide Subtree hide-subtree Hide subheads and body associated with a given heading.
C-c C-c HideHide Entry hide-entry Hide the body associated with a particular heading (not subheads and their bodies).
C-c C-l HideHide Leaves hide-leaves Hide the body of a particular heading and the bodies of all its subheads.
C-c C-s ShowShow Subtree show-subtree Show the subheads and text associated with a given heading.
C-c C-e ShowShow Entry show-entry Show the body associated with a particular heading (not subheads and their bodies).
C-c C-k ShowShow Branches show-branches Show the body of a heading and bodies of all its subheads.
C-c Tab ShowShow Children show-children Show the next level of subheads associated with a particular heading (none of body text).

7.5 Rectangle Editing

When you mark regions to move or delete, they always cover the full width of the window. Editing by region is fine for most of the work that you do in Emacs. But what if you wanted to edit a table? Regions cover the full width of the window, so they can't handle columns. Emacs offers another way to define areas to delete, copy, and move around: using rectangles. Rectangles are just what they sound like: rectangular areas that you define and manipulate using special rectangle editing commands. Editing with rectangles is useful whenever you want to move or delete vertical columns of information; for instance, moving a column of a table or rearranging fields in a dataset.

For example, let's say you want to edit the following table, moving the "Hours" column to the right side. There's no way to do this using regions, but it's easy to do if you learn some rectangle editing commands.


Initial state:

A flextime schedule.


You define a rectangle the same way you define a region; the commands you use after marking the area tell Emacs whether you want to work with a region or a rectangle. (This is a good time to let go of your mouse and use keyboard commands for marking the text. Highlighting remains horizontal when you're working with rectangles and will only confuse you as you begin to think rectangularly. Of course, there's nothing wrong with using the mouse to move the cursor quickly; just don't use it to highlight text.)

Before we start working with these columns, select the buffer with C-x h and untabify it by typing M-x untabify. Rectangle editing works best with files that do not contain tab characters.

To define a rectangle, move the cursor to the upper-left corner and set the mark by pressing C-Space, then move the cursor to the lower-right corner of the rectangle. Once you're at the lower-right corner of the rectangle, move one character farther. Why move one character farther? Remember that when you define a region, the character that the cursor is on isn't part of the region. (The character that the mark is on is part of the region.)

Let's define a rectangle that covers the second column of our table.


Move to the

H
in
Hours
and type C-Space

The mark is set at the upper-left corner of the rectangle to be moved.


Move the cursor to the space following the bottom-right corner of the rectangle, the

c
in
chipmunk
.

The cursor follows the bottom-right corner of the rectangle.


Now that the rectangle is marked, we want to delete it and then move it. The command to delete a rectangle so you can retrieve it elsewhere is C-x r k (for kill-rectangle).


Type: C-x r k

The rectangle is deleted; it's in a special rectangle kill buffer.


Once again, when you mark a rectangle, you put the cursor on the upper-left corner, set the mark, then move to the lower-right corner of the rectangle and over one more space. Emacs expects rectangles to be rectangles. If necessary, it pads an area with spaces to make up the straight line on the right side.

You can move anywhere on the screen and reinsert the rectangle last killed with the yank-rectangle command, C-x r y. To put the "Hours" column on the right side of the table, we move the cursor following the cell phone column.


Place the cursor following

Cell
and press M-10 Space to move to a good location to paste the "Hours" column:

Move the cursor to where we want to reinsert the rectangle.


Type: C-x r y

Emacs inserts the rectangle we killed earlier.


Emacs inserts the rectangle exactly where you tell it to. We moved past the cell phone column and then added some space between the cell phone and hours columns. Otherwise, Emacs would have blithely inserted the hours column into the middle of the cell phone column. Note that there's no equivalent of the kill ring for rectangles. You can yank only the most recent rectangle.[38]

Killing and yanking rectangles requires practice. Once you get the hang of the procedure, it is an easy way to edit tables and other column-dependent material.

A few other commands create blank rectangles. For example, let's say we want to put four more spaces between the cell phone and hours columns. To do this, we set the mark, move to the bottom of the column, move forward four spaces, then type C-x r o (for open-rectangle). This command inserts a blank rectangle and pushes the remaining text to the right.


Move the cursor to the

H
in
Hours
and type C-Space

Emacs sets the mark at the upper-left corner of the rectangle.


Now we need to define the amount of space we want to insert. Move down to the bottom of the rectangle (the "Alvin" line) and then move to the hyphen between

6:00
and
3:00
.


Move the cursor following

6:00
.

The lower right corner of the rectangle is defined.


Finally, type C-x r o to add the new space to the table.


Type C-x r o

Emacs inserts a blank rectangle that is four spaces wide. It moves the rest of the table to the right.


The clear-rectangle command wipes out text, leaving a blank rectangle in its place. It's just as though you had erased a column on a blackboard. Like the blackboard column, the text column that is wiped out is gone, not stored in the rectangle kill buffer. To continue with our example, let's say that after reviewing the schedule, all those involved agreed that they'd rather not have their cell phones listed.


Move the cursor to the

C
in
Cell
and type C-space.

The upper-left corner of the rectangle to be cleared is marked.


Move to the space following the last phone number and type: C-x r c

The clear-rectangle command removes the "Cell Phone" column and leaves a blank space in its place.


As you can see, the spacing of our table still isn't perfect; you'd probably want to use the delete-rectangle command[39] to delete the extra space between the second and the third columns. To delete the blank space without storing it, start by moving the cursor to the space following the longest email address and press C-Space to set the mark, then move to the opposite corner of the box you want to delete and type C-x r d.


On the header line, move to the column after the longest email address and press C-Space

The upper-left corner of the rectangle to be deleted is marked.


Move a few spaces before 6:00 on the last line and type C-x r d

The delete-rectangle command deletes the blank space.


If you're doing some really fancy table editing, being able to store several rectangles is helpful. That way, you can have every column as a rectangle, as well as having a rectangle for the exact amount of blank space to put between each column. You can store rectangles in registers by typing C-x r r

r
where
r
is any alphanumeric character, including punctuation. To insert a rectangle you've stored, type C-x r i
r
. Registers don't persist between sessions.

Table 7-5 lists rectangle commands.


Table 7-5. Rectangle commands

Keystrokes Command name Action
C-x r k kill-rectangle Delete a rectangle and store it.
C-x r d delete-rectangle Delete a rectangle and do not store it.
C-x r y yank-rectangle Insert the last rectangle killed.
C-x r c clear-rectangle Using spaces, blank out the area marked as a rectangle and do not store it.
C-x r o open-rectangle Insert a blank rectangle in the area marked.
C-x r r r copy-rectangle-to-register Copy rectangle to register
r
(where
r
is any character) .
C-x r i r insert-register Insert rectangle from register
r
(where
r
is any character).
(none) delete-whitespace-rectangle If a rectangle includes initial whitespace, deletes it, narrowing rectangle.
C-x r t string Enter string-rectangle Change contents of marked rectangle to
string
(if
string
is narrower or wider than rectangle, dimensions change accordingly).
(none) string-insert-rectangle Prompts for string and inserts rectangle.

7.5.1 CUA Rectangle Editing

If you are familiar with CUA mode, which is part of Emacs starting with 21.3.5, you may know that it provides cut and paste key sequences familiar to Windows users, as in C-x to cut and C-v to paste (see Chapter 13). The second most commonly touted feature of CUA mode is its superior rectangle support.

We've just looked at a myriad of rectangle commands. CUA's rectangle support is far simpler. By learning essentially one command, you can cut and paste rectangles in CUA mode.

Unfortunately at present, CUA mode support is standard but not nuanced on Emacs 21.3.5. You either take the whole enchilada or you don't. To turn it on, select C-x/C-c/C-v cut and paste (CUA) from the Options menu. If you don't generally like to use the CUA keybindings for cut and paste, you might turn this option on only when you are doing rectangle editing.

To select a rectangle, type Shift-Enter. Emacs starts to highlight in a dark pink color by default. You extend the highlighting with normal cursor movement keys (the mouse does not work at present).


Move to the

C
in
Cell
and type: Shift-Enter

The upper-left corner of our rectangle is marked (Windows).


The minibuffer displays an array of CUA mode rectangle commands. For now, we'll just mark the rectangle and experiment with one of these commands momentarily.


Move the cursor to the last number in Alvin's phone number.

The rectangle is marked (Windows).


Note that the marked rectangle isn't strictly rectangular in shape. The phone numbers form a true rectangle, but in order to create a rectangle that includes the column header, we need to ask CUA mode to "pad" the rectangle using M-p, one of the commands listed in the minibuffer earlier.


Type: M-p

The pad command makes this a true rectangle (Windows).


We can now cut or paste the rectangle using C-x or C-v respectively. This is just a taste of the CUA mode rectangle commands. You can explore more of them on your own. We thought you should be aware of this method as an alternative to the more keyboard-intensive rectangle commands that have been part of Emacs for many years.

7.6 Making Simple Drawings

Emacs is not, by any means, a graphics package, but it does provide some limited drawing capabilities. Emacs includes a picture mode that allows you to draw simple pictures using keyboard characters; it also includes artist mode, which enables you to draw quickly using the mouse.

Why would you want to draw with Emacs? Well, Emacs is useful for inserting a quick drawing or diagram in a mail message, something that most graphics packages can't do. It's also good for making block diagrams, timing diagrams (for electrical engineers), timelines, and other simple drawings.

Don't overlook this simple facility! We have seen many papers that were carefully formatted with a simple star-and-bar diagram dropped in the middle. Sure, you can use a graphics package to create a much nicer drawing, but if that's not your area of expertise, an Emacs ASCII drawing might be just the ticket.[40] We discuss picture mode first and then artist mode.

Picture mode turns the area being edited into a kind of drawing board consisting of columns and rows. In picture mode, you can create simple pictures (such as the one in Figure 7-3) using keyboard characters without having them "rearranged" by the word-wrap capabilities of auto-fill mode, for example.


Figure 7-3. Drawing in picture mode


To enter picture mode, type M-x edit-picture. The word

Picture
appears on the mode line, followed by the default drawing direction (more on that shortly). Typing C-c C-c exits picture mode and returns you to whatever major mode you were in before.

7.6.1 Drawing in Picture Mode

In picture mode, you can "draw" with any character in any of eight directions. Although you can draw in eight directions, only one direction is available at a time; this direction is referred to as the default direction. When you first enter picture mode, the default direction is right, meaning that if you press the hyphen key four times, you would draw a line to the right, as follows:

——
. The default direction is displayed on the mode line, like this:

(Picture: right)

By typing special commands that change the default direction, you can draw in seven other directions as well. For example, C-c \ makes the default direction "southeast;" the mode line would then read

(Picture: se)
. If you typed four hyphens in this direction, they would look like stair steps:

-

 -

 -

  -

Figure 7-4 illustrates the commands for setting various directions as the default in picture mode.


Figure 7-4. Moving around in picture mode


Picture mode tries to make these commands easy to remember, and it doesn't do too badly: for example, C-c ^ points upward, C-c-` arguably points to the northwest, and so on. If you can come up with a good mnemonic device for C-c . let us know! Maybe you can think of it as "dot for down."

After you set a default direction, pressing any character repeatedly draws a line of characters in that direction. Give it a try in a scratch buffer, using the commands in the figure to change the default direction. Try drawing a box.[41]


Type: M-x picture-mode

Putting the buffer into picture mode, default direction "right."


Type: Tab M-20 -

Emacs draws a line to the right. Next, we'll change the default direction to down, and use | for the right side of the square.


Type: C-c . M-5 |

Emacs draws a line down. Now we'll set the default direction to "left," then draw the bottom of the square.


Type: C-c < M-20 -

Emacs draws a line to the left. Next, use C-c ^ to set the default direction to "up," and then draw vertical bars back to the starting point.


Type: C-c ^ M-5 |

Emacs draws a line up that completes the box.

7.6.2 Editing in Picture Mode

By now, you should have a basic understanding of what picture mode can do for you. It's one of the more complicated minor modes because it redefines what many of the major editing keys do—and with good reason. The editing techniques you use for most ASCII files just won't work well for pictures. You don't really want to insert characters; the standard insert mode would prevent you from editing effectively, because any character you type distorts the rest of the line. Therefore, picture mode implicitly changes to overwrite mode. Many other features are redefined—some in insignificant ways, others in more substantial ways.

Therefore, to do justice to picture mode, we have to revisit most of the basic editing concepts. Please bear with us, or skip this section if you aren't interested in pictures. Let's start at the beginning: basic cursor motion.

7.6.2.1 Cursor motion in picture mode

Picture mode makes some small but important changes in the basic cursor commands. There's an easy way to summarize these changes: in picture mode the buffer becomes a grid of rows and columns. For example, consider what C-f does in most other modes: it moves forward through the file, one character at a time. Typing C-f repeatedly moves the cursor to the left, then at the end of the line, it jumps to the first character on the next line. picture mode, C-f means "move to the right." When you reach the end of the line in picture mode, C-f doesn't wrap to the next line; it continues adding characters to the current line.

C-p and C-n become vertical "up" and "down" commands, respectively. Try editing some sample text, moving to the end of a line, and typing C-p. Normally, as you type C-p, the cursor stays at the end of the line; if the previous line is short, the cursor moves to the left when it goes up. In picture mode, C-p and C-n always move up (or down) in a straight line.

You can get to every place you need to go with C-f, C-b, C-p, and C-n. The arrow keys work too, but you may want to know the cursor movement commands for moving in the default direction as well, so you can also go sideways when it's faster. C-c C-f moves you forward in the default direction (so "forward" here could mean to the left, right, up, or down, as well as all directions in between). C-c C-b moves you backward in the default direction. (Moving "up" or "down" relative to the default direction isn't defined.)

For example, let's say you had drawn the house shown in Figure 7-1 and you wanted to move the cursor down the left side of the roof. You would set the default direction to "southwest" by typing C-c /. If the cursor were on the top shingle on the left side of the roof, typing C-c C-f would move you down the left side of the roof and typing C-f would move you to the top-right shingle, as shown in Figure 7-5.


Figure 7-5. Using the default direction versus typical cursor movement commands

7.6.2.2 Inserting blank lines

As you continue to work in picture mode, you'll find a few more surprises. Pressing Enter in picture mode moves you to the beginning of the next line, without inserting a blank line—on the assumption that you probably don't want to change the relationship between lines. If you want to insert a new line, type C-o; an empty line appears beneath the current line, and the cursor does not move. For example, the cursor is initially on the 0 in the first line. If we want to open another line between the two, we type C-o.


Initial state:

Initial text; the cursor is on the 0 in the first line.


Type: C-o

C-o opens a new line but doesn't move the cursor.


One of the more difficult things to do in picture mode is to type a standard carriage return that breaks a line in the middle. You can move to a point in the middle of a line, type C-k to kill the right-hand portion, type C-o to insert a blank line; type Enter to move to the beginning of this blank line, and type C-y to yank the right-hand part of the line back. Or you can use the split-line command (C-M-o), and then delete the blank space at the beginning of the new line.

Deletion isn't quite the same, either. In picture mode C-c C-d is the delete character command that you're used to: it deletes the character under the cursor and moves the rest of the line to the left. An unadorned C-d deletes the character under the cursor, replacing it with a space. Del deletes the character to the left of the cursor, replacing it with a space.

Table 7-6 contrasts the picture mode commands with their normal text mode behavior.


Table 7-6. Picture mode v. text mode

Keystrokes In text mode In picture mode Picture mode alternative
Enter Insert a blank line. Move the cursor to the beginning of the next line. C-o inserts blank lines.
C-d Delete the character and move the text to left. Replace the character with Space and don't move. C-c C-d is like C-d in text mode.
Space Move the text to the right and insert a space. Move the cursor to the right and delete any character you space over. None; go back to text mode to insert blank spaces.
C-k Erase the text on the current line; pressing C-k twice deletes a line. Erase the text on the current line; it doesn't delete the line. To delete a line, go back to text mode or use delete-rectangle.
Tab Insert tabs and move the remaining text to the right. Move the cursor across the screen but don't affect the underlying text. To insert a tab's worth of space, go back to text mode.
C-n Move to the next line. Move down, staying in the same column. (none)
C-p Move to the previous line. Move up, staying in the same column. (none)
C-f Move one character forward in the file. Move one character to the right. (none)
C-b Move one character backward in the file. Move one character to the left; stop at the beginning of the line. (none)

If you want to insert a block of blank space, you can use a rectangle command such as open-rectangle. See the discussion of this command earlier in this chapter for more information. Also, if you want to insert blank space at the end of a line, you can use C-f.

To perform some tasks, you may find it easier to switch back temporarily to the mode you're used to. C-c C-c moves you back to the mode you were in before you entered picture mode. Make any necessary changes, then enter picture mode again by typing M-x picture-mode.

If you want to move something you've drawn, the easiest way is to use rectangles, as described earlier in this chapter.

Tabs are also different in picture mode. By default, picture mode interprets the following characters as tab stops if they appear by themselves on a line: exclamation point (!), hyphen (-) and tilde (~). If these characters appear on a line and the user presses tab on the next line, these characters are presumed to denote tab stops. You can change this behavior by setting the variable picture-tab-chars to other characters. If the characters appear with normal text, they are not interpreted as tab stops. To use these characters as tab stops, press Esc-Tab (for picture-tab-search).

Table 7-7 summarizes the commands for editing in picture mode.


Table 7-7. Picture mode commands

Keystrokes Command name Action
(none) picture-mode or edit-picture Enter picture mode.
C-c C-c picture-mode-exit Exit picture mode and return to the previous mode.
C-c ^ picture-movement-up Set the default drawing direction to up.
C-c . picture-movement-down Set the default drawing direction to down.
C-c > picture-movement-right Set the default drawing direction to right.
C-c < picture-movement-left Set the default drawing direction to left.
C-c ` picture-movement-nw Set the default drawing direction to northwest.
C-c ` picture-movement-ne Set the default drawing direction to northeast.
C-c / picture-movement-sw Set the default drawing direction to southwest.
C-c \ picture-movement-se Set the default drawing direction to southeast.
C-c C-f picture-motion Move the cursor forward in the default drawing direction.
C-c C-b picture-motion-reverse Move the cursor backward in the default drawing direction.
C-f picture-forward-column Move the cursor to the right one character.
C-b picture-backward-column Move the cursor to the left one character.
C-n picture-move-down Move the cursor down one character.
C-p picture-move-up Move the cursor up one character.
C-d picture-clear-column Blank out the character under the cursor; doesn't move remaining text to the left.
C-c C-d delete-char Delete the character under the cursor and move the remaining text to the left.
C-k picture-clear-line Delete the text on the current line; the line is not deleted if used twice.
C-o picture-open-line Insert a blank line.
C-c C-w
r
picture-clear-rectangle-to-register Clear the rectangle and save it in register
r
.
C-u C-c C-w
r
picture-clear-rectangle-to-register Delete the rectangle and save it in register
r
.
C-c C-x
r
picture-yank-rectangle-from-register Insert the rectangle saved in register
r
at the cursor position.
C-c C-r picture-draw-rectangle Draw a rectangle around current region.
C-c C-y picture-yank-rectangle Paste rectangle.
C-c C-k picture-clear-rectangle Erase rectangle.
C-c Tab picture-set-tab-stops Set tab stops applicable only in picture mode (!, -, and ~ denote tab stops by default).
M-Tab picture-tab-search Move to the next picture mode tab.

7.6.3 Drawing with the Mouse Using Artist

We would be remiss if we didn't introduce you to artist mode, an easy way to create ASCII art using the mouse. (You can also use keyboard commands, but trust us—you won't want to.)

Artist mode is a minor mode related to picture mode, so you use them together. For example, you might draw using artist mode, then edit the picture in picture mode. Or you might choose to use artist mode alone for your creations.

We're going to give you a taste of artist mode; you can perfect your skills in your spare time. When you start artist mode, picture mode starts automatically.


Type: M-x artist-mode

Artist appears on the mode line, as does Picture.


When you start artist mode, pen drawing is selected by default.


Hold down the left mouse button and move around to scribble.

A random scribble.


With the pen, you can draw freestyle. Hold down the middle mouse button and a menu appears, with Drawing, Edit, and Settings submenus. The Drawing menu offers a variety of shapes from which to choose. Now that we've scribbled, let's create some graffiti using the spray can.


Select Spray Can from the Drawing menu, then spray the screen by holding down the left mouse button and moving the mouse.

A random spray.


We aren't going to go deep into artist mode, but we would like to give you a flavor of the basic drawing choices. You can draw rectangles (our personal favorite), ellipses, lines (which strive to be straight), and poly-lines (which strive to be polygon-angular). Figure 7-6 shows a representative sample of shapes. With practice, you can create complex drawings and edit them, either using the mouse or using standard picture mode commands.


Figure 7-6. A representative sample of artist shapes


For rectangles, lines, and ellipses, hold down the left mouse and pull them to the size and, in the case of lines, angle you prefer. (Ellipses are made of straight lines, so use your imagination; this is ASCII art after all.) For poly-lines, draw a line by holding down the left mouse button, then release it. Move the mouse away from that line to the next corner of the polygon and click. Emacs draws a line connecting the two points. Poly-lines allow you to create polygons quickly.

Table 7-8 provides an overview of artist commands. Artist works very well with the mouse and the middle-button mouse menu; if you're mouse-averse, you'll prefer picture mode.


Table 7-8. Artist mode commands

Keystrokes Command name Action
(none) artist-mode Enter artist mode.
C-c C-c artist-mode-off Exit artist mode.
C-f artist-forward-char Move to the right one character (at end of line, keep adding characters to current line).
C-b artist-backward-char Move to the left one character (at beginning of line, does nothing).
C-n artist-next-line Move down a column (at end of buffer, keep adding lines to the buffer).
C-p artist-previous-line Move up a column (at first line of buffer moves to first position in file, then does nothing).
C-c C-a C-o or Mouse-2 artist-select-operation Select an operation (press Tab to see a list).
C-c C-a f` Artist menuEditFlood-fill artist-select-op-flood-fill Select flood fill as the operation.
C-c C-a C-k Artist menuEditCut artist-select-op-cut-rectangle Draw a rectangle around an area, then cut.
C-c C-a M-w Artist menuEditCopy artist-select-op-copy-rectangle Draw a rectangle around an area, then copy.
C-c C-a C-y Artist menuEditPaste artist-select-op-paste Paste what you copied wherever you click the mouse.
C-c C-a v Artist menuDrawingVaporize artist-select-op-vaporize-line Erase a line you select (literal line; not a line in the file).
C-c C-a C-d Artist menuDrawingErase artist-select-op-erase-char Set operation to erase (use the mouse as your eraser).
C-c C-a S Artist menuDrawingSpray-can artist-select-op-spray-can Set operation to spray can.
C-c C-a e Artist menuDrawingEllipse artist-select-op-ellipse Draw ellipses.
C-c C-a p Artist menuDrawingPoly-line artist-select-op-poly-line Draws poly-lines.
C-c C-a r Artist menuDrawingRectangle artist-select-op-rectangle Draw rectangles.
C-c C-a l Artist menuDrawingLine artist-select-op-line Draw lines.
C-c C-a C-r Artist menuSettingsRubber banding artist-toggle-rubber-banding If on (the default), show shape while stretching; if not, mark end-points.
C-c C-a C-l Artist menuSettingsSet Line artist-select-line-char Select character to use when drawing lines (- is the default).
C-c C-a C-f Artist menuSettingsSet Fill artist-select-fill-char Select character to fill shapes with (Space is the default).

7.6.4 Problems You May Encounter

Artist mode says you can't change to another shape while drawing. Exit artist mode and then reenter. Before drawing anything, click the mouse's middle button to display the pop-up menu and select the desired shape from the Drawing menu.

Загрузка...