-->
Previous | Table of Contents | Next |
Big-Movement Keys
If you want to move through a file a screen at a time, which is more efficient than pressing <Page Down>, use commands that scroll through a file. The command <Ctrl-x><]> moves you forward one page. The scrolling keystrokes are as follows:
To move quickly to the last line of the file or buffer, press <Esc><Shift-.>. To move to the first line of the file, press <Esc><Shift-,>. In fact, to move to a specific line in the buffer, type the command goto-line n, where n is the line number you want to move to. To move to line 35 of the file (if there is a line 35), press <Esc>, enter goto-line 35, and press <Return>.
You can repeat any command you want by pressing <Esc-n>, where n is the number of times you want to repeat the command, and then entering the command you want to repeat.
Take a little time to practice positioning the cursor by using the commands described in these last few sections. Remember that you must be in command mode for the cursor-positioning commands to work.
To add text to the editing buffer, you must position the cursor at the position you want to start entering text. Any usual text characters you type are then added to the buffer. If you press <Return>, emacs opens, or adds, a line to the buffer. Before you start adding text, first position the cursor at the location you want to add text. You then simply type the text.
To add a line of text below the current line, you use the command <Ctrl-o>. This opens a line in the buffer and allows you to add text. In the following example, you add a line to some existing text.
Before:
All jobs complete please call if you have any questions.
The cursor is on the second line. Press <Ctrl-o> to add a line or lines below that line, and then type the following:
Lee Nashua 555-1837
After:
All jobs complete please call Lee Nashua 555-1837 if you have any questions.
Although you added only two lines, you could have added more lines by pressing <Return> at the end of each line. Naturally, you could have added only one line by not pressing <Return> at all.
Making corrections or modifications to a file may involve deleting text. With emacs, you can delete a character, a word, a number of consecutive words, all the text to the end of a line, or an entire line. Because emacs is a visual editor like vi, the characters, words, or lines are removed from the screen as you delete them.
Table 28.1 lists the delete commands and describes their actions. They all take effect from the current cursor position. Move the cursor to the character, word, or line you want to change and then issue the desired delete command. Practice using them to see their effect. Youll find they are helpful in making corrections to files.
Keystroke | Action |
---|---|
<Ctrl-d> | Deletes character at the cursor position |
<Esc><d> | Deletes the word the cursor is on |
<Ctrl-k> | Deletes from the cursor position to the end of the line |
<Esc><k> | Deletes the sentence the cursor is on |
<Ctrl-w> | Deletes a marked region (see Marked Text later in Table 28.4 for commands for marking a region) |
If you use the <Ctrl-k> command, the information just doesnt disappear into the bit bucket. The characters deleted are added to a kill buffer, which you can yank back at any time with the <Ctrl-y> command.
Previous | Table of Contents | Next |