|
|
Question #1: Should you learn vi?
tigger vi man page (AIX), icarus
vi man page (Solaris) |
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
There are three basic modes of vi: Command mode This is the default when you
enter vi. In command mode, most letters, or short sequences of letters, that
you type will be interpreted as commands, without explicitly pressing Enter . If you
press Esc when you're in command mode, your terminal will beep at you.
This is a very good way to tell when you're in command mode. Insert mode In insert mode, whatever you type
is inserted in the file at the cursor position. Type a (lowercase
letter a, for append) to enter insert mode from command mode; press Esc
to end insert mode, and return to command mode. Line mode Use line mode to enter line
oriented commands. To enter line mode from command mode, type a colon ( : ). Your cursor moves to the bottom of the
screen, by a colon prompt. Type a line mode command, then
press Enter. Any sensible command from the Unix line editor ex will
work, and a few are good to know about. These commands are indicated in this
handout by a colon in front of the command. Each time you use a line mode
command, you must type a colon to enter line mode, then type the command by
the colon prompt at the bottom of the screen, then press Enter when
you finish typing the command. (The search commands starting with / and ? work similarly. |
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
Many commands take number prefixes; for example 5w
moves to the right by 5 words.
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
Note: dd or any other delete will save a
copy of the deleted string in the same general buffer. Therefore a cut and
paste can be done with dd and p,
rather than copy and paste with yy and p.
But make sure not to overwrite the buffer with some other yank or delete command
before you have a chance to paste. |
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
|
|
||||||||||||||||||||||||||||||||
|
|
The .exrc file in your login directory is
a collection of vi commands to customize that environment. For example, an .exrc file containing: :set showmode tells vi to show the words INPUT MODE in the lower right-hand
corner of the screen when in Insert mode, and :set ic
tells the editor to ignore case during searches. To temporarily
tell vi to respect case during searches, enter :set noic before searching. When you leave and reenter vi,
your .exrc file takes effect again so that
case is ignored during searches.
|
|
||||||||||||||||||||||||||||||||