hmmmm... vi in 25 words or less: I recommend you get O'Reilly's book on vi. HP also wrote a good one, but I think it is out of print. vi will seem really klunky at first and you will probably hate it. But you know you are a real Unix when you can get around in vi and learn all that it can do.
Here are some hints to get you going:
to exit without saving:
:
q
!
to save and exit:
:
w
q
!
to change a word:
press l to move the cursor to the right until you are on the word. or press h to move the cursor to the left until you are on the word. then:
cw
<type in your changes>
Esc
to delete a word:
move the cursor as above. then:
dw
One of the basic things to get used to with vi is that it has two modes; command mode (when it beeps at you a lot and seems to ignore what you want it to do) and insert mode (when what you type actually gets inserted into the document). Every time you hit "Esc" as described by Bi above you are returning to command mode.
When in command mode a lot of the commands are done in two steps, command then movement. For example, you could hit 'd' to delete some text, and then '}' to move to the end of the current paragraph, in which case it would remove from your current position to the end of the paragraph.
The following is what I offer to anyone that asks how to drive VI, cut & paste it somewhere for later.
Enjoy, Laurie.
>--------- Help File For Basic VI ------------<
Command Mode
Escape to command mode (use the Esc key)
Exiting from VI
:wq! Write changes & Quit
:q! Quit without saving changes
Inserting Text
i Insert text before cursor
I Insert text at start of line
a Add text after cursor
A Add text at end of line
o Open new line below cursor
O Open new line above cursor
R Start replacing text
Changing Text
r Replace one character at cursor
s Substitute One Character
cw Change word
C Change to end of line
cc Change whole line
5cc Change 5 lines
Deleting text & lines
x Delete current character
X Delete previous character
dw Delete word
D Delete to end of line
dd Delete one entire line
5dd Delete 5 lines
How to move around
Up Arrow Move Up line by line
Down Arrow Move Down line by line
Left Arrow Move Left Char by Char
Right Arrow Move Right Char by Char
OR
h Left
J Down
k Up
l Right
/ Pattern search forward
? Pattern search backward
0 Move to start of line
$ Move to end of line
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.