Datasheet
Task 1.5: Edit Files
27
Now that you’ve duplicated the necessary lines, you must modify one copy to point to the
kernel whose entry was accidentally deleted. To do so, follow these steps:
1. Move the cursor to the v in vmlinuz on the second image= line. You’re about to begin
customizing this second stanza.
2. Up until now, you’ve operated Vi in command mode. There are several commands that
you can use to enter insert mode. At this point, the most appropriate is R, which enters
insert mode so that it is configured for text replacement rather than insertion. If you prefer
to insert text rather than overwrite it, you could use i or a (the latter advances the cursor
one space, which is sometimes useful at the end of a line). For the purpose of these instruc-
tions, type R to enter insert mode. You should see -- REPLACE -- appear in the status line.
3. Type the name of a new Linux kernel. For the purpose of this example, let’s say it’s called
bzImage-2.6.13, so that’s what you’d type. This entry should replace vmlinuz.
4. Use the arrow keys to move the cursor to the start of linux on the next line. You must
replace this label so that your new entry has its own label.
5. Type a new label, such as mykernel. This label should replace the existing linux label.
6. Exit from insert mode by pressing the Esc key.
7. Save the file and quit by typing :wq. This is an ex mode command that writes changes and
then exits (quits) from the editor. (The ZZ command is equivalent to :wq.)
Many additional commands are available that you might want to use in some situations.
Here are some of the highlights:
Case changes Suppose you need to change the case of a word in a file. Instead of entering
insert mode and retyping the word, you can use the tilde (~) key in command mode to change
the case. Position the cursor on the first character you want to change and press ~ repeatedly
until the task is done.
Undo To undo any change, type u in command mode.
Opening text In command mode, typing o opens text—that is, it inserts a new line immedi-
ately below the current one and enters insert mode on that line.
Searches To search forward for text in a file, type / in command mode, followed immedi-
ately by the text you want to locate. Typing ? will search backward rather than forward.
Changes The c command changes text from within command mode. You invoke it much as
you do the d or y commands, as in cw to change the next word or cc to change an entire line.
Go to a line The G key brings you to a line that you specify. The H key “homes” the cur-
sor—that is, it moves the cursor to the top line of the screen. The L key brings the key to the
bottom line of the screen.
Global replacement To replace all occurrences of one string by another, type :%s/
original/replacement, where original is the original string and replacement is its
replacement. Change % to a starting line number, comma, and ending line number to perform
this change on just a small range of lines.
83484.book Page 27 Monday, September 18, 2006 8:58 AM










