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-fdoes in most other modes: it moves forward through the file, one character at a time. Typing C-frepeatedly 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-fmeans "move to the right." When you reach the end of the line in picture mode, C-fdoesn't wrap to the next line; it continues adding characters to the current line.
C-pand C-nbecome 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-pand C-nalways 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-fmoves 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-bmoves 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-1and 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-fwould move you down the left side of the roof and typing C-fwould 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 Enterin 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-oopens 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-kto kill the right-hand portion, type C-oto insert a blank line; type Enterto move to the beginning of this blank line, and type C-yto yank the right-hand part of the line back. Or you can use the split-linecommand ( 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-dis 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-ddeletes the character under the cursor, replacing it with a space. Deldeletes the character to the left of the cursor, replacing it with a space.
Table 7-6contrasts 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-oinserts blank lines. |
C-d |
Delete the character and move the text to left. |
Replace the character with Spaceand don't move. |
C-c C-dis like C-din 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-ktwice 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-cmoves 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-charsto 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).
Читать дальше