4.2 Options When Starting viIn this handbook, you have invoked the vi editor with the command:
$
There are other options to the 4.2.1 Advancing to a Specific PlaceWhen you begin editing an existing file, you can call the file in and then move to the first occurrence of a pattern or to a specific line number. You can also specify your first movement by search or by line number right on the command line:
In the file practice , to open the file and advance directly to the line containing the word Screen , enter:
If you include spaces in the pattern , you must enclose the whole pattern within single or double quotes:
or escape the space with a backslash:
In addition, if you want to use the general pattern-matching syntax described in Chapter 6, Global Replacement , you may need to protect one or more special characters from interpretation by the shell with either single quotes or backslashes.
Using
4.2.2 Read-only ModeThere will be times when you want to look at a file but want to protect that file from inadvertent keystrokes and changes. (You might want to call in a lengthy file to practice vi movements, or you might want to scroll through a command file or program). You can enter a file in read-only mode and use all the vi movement commands, but you won't be able to change the file. To look at a file in read-only mode, enter either:
or:
(The
or:
If you have a problem writing out the file, see the problem checklists summarized in Appendix D, Problem Checklist . 4.2.3 Recovering a Buffer
Occasionally there is a system failure while you are editing a file.
Ordinarily, any edits made after your last write (save) are lost.
However, there is an option, When you first log on after the system is running again, you will receive a mail message stating that your buffer has been saved. In addition, if you type the command:
or:
you will get a list of any files that the system has saved.
Use the
$ It is wise to recover the file immediately, lest you inadvertently make edits to the file, and then have to resolve a version skew between the preserved buffer and the newly edited file.
You can force the system to preserve your buffer even when there is
not a crash by using the command |
|