Книга: Learning GNU Emacs, 3rd Edition

7.6.2.2 Inserting blank lines

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.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.103. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз