Notes - UNIX I

Tuesday, June 9, 1998

Previous Day's Notes | Back to main page | Next Day's Notes

vi (doesn't rhyme with "pie") is the visual mode of ex. It looks like a full-screen editor (really isn't).
vi is ex in visual mode plus additional commands. It's still a buffer editor. However, if connection is lost while in vi, it will send you email and ask you if you want to recover your interupted session and will show you what to do.
Must be on the proper terminal (VT100, which is the most popular terminal ever. It's the standard emulation. If you can use the "talk" command, you can use vi.
(If you still have problems connecting, try typing: set term vt100 (while logged on to Clyde.))

You will never be finished learning vi. Make it a point to learn a new command every day you use vi.

To invoke vi, type:
vi [ENTER]
vi
starts off in command mode only. There are two modes of vi: command mode and text entry mode.
**To exit from any text entry mode, hit [ESC]**
There are 4 ways to exit vi:

When in command mode, you don't see the commands on the screen. The [DELETE] key will let you abort from a partially-typed command, or you can just hit [ESC].

[ENTER] is not usually used for entering commands.

:set commands

8-11 (Lefthand)

:set x
:set nox
:set x=val
:set
:set all
:set x?
Enable option x.
Disable option x.
Give value to option x.
Show changed options.
Show all options.
Show value of option x.
:set showmode
(:set noshowmode)
In insert mode, displays a message on the prompt line indicating the type of insert you are making. For example, "Open Mode," or "Append Mode."
:set nu
(:set nonu)
Display line numbers on left of screen during editting session.
:set all Show all options.
Other vi command-mode commands:
A Append by moving to end of line and enter text-entry mode after last character.
a Append by entering text-entry mode after character the cursor is on.
dd Delete line that cursor is on.
#dd Delete # of lines starting with the line the cursor is on.
Many commands can be preceded by a number to indicate how many lines are to be affected by the command.
D Erases everything from charactor cursor is on to the end of the line.
u Undo last command. (The newer versions of Linux have multiple undos.
U Restore current line, discarding changes.
i Insert in front of character that cursor is on.
x Deletes character the cursor is on.
(Can also use: #x, where # is the number of characters to delete in one swell foop.)
I Insert at beginning of the line the cursor is on.
o Open mode: opens a new line after the line the cursor is on.
O Open mode: opens a new line before the line the cursor is on.
r Replaces the single character the cursor is on without changing to text-entry mode.
R "Overtype" mode: writes over existing characters until you hit [ESC] to leave this mode.
~ Changes the case of the letter the cursor is on when typed.
J Join current line with previous.
5J Join 5 lines.
! Shell commands.
[CTRL-l] or [CTRL-r] Clears screen from interuptions (messages from other users).
de Delete from cursor to end of line.
dM Delete from cursor to middle of screen.
dG Delete from cursor to end of file.
d^ Delete from cursor to beginning of line.
d0 Delete from cursor to first column of line.
yw Yank one word (that cursor is on).
P Paste from anon buffer before cursor.
p Paste from anon buffer after cursor.
cw Change entire word (cw[ENTER] then type new word, then press [ESC] to exit).

Previous Day's Notes | Back to main page | Next Day's Notes