Using the vi Editor.doc

advertisement
CSIS-80
LECTURE 6
Chapter 8
VI
"It's a vi thing - you wouldn't understand."
The Cult of vi
"Emacs is a hideous monstrosity, but a functional one. On the other hand, vi is a masterpiece of elegance.
Sort of like a Swiss Army knife versus a rapier."
See also:
http://www.splange.freeserve.co.uk/misc/vi.html
the cult of vi
http://www.thomer.com/thomer/vi/vi.html#why
http://www.sunworld.com/swol-10-1995/swol-10-software.html
vi lover's home page
vi vs. emacs
MODES
1.
What are the three modes that vi can be in?
2.
What mode is vi in when it starts?
3.
How do you move from command mode to insert mode (three ways)?
4.
How do you move from insert mode back to command mode?
5.
How do you get to 'last line' mode if you are in insert mode?
6.
How do you save a file? How do you quit vi and save your file at the same time? How
do you quit vi without saving your file?
MOVING THE CURSOR
7.
In addition to the arrows, you can use the following keys to move: k up, j down, h left,
l right.
8.
The letters b and w move the cursor backwards and forwards by one word.
9.
The letters 0 and $ move the cursor to the beginning and the end of a line.
ACTIVITIES
in Unix, open a file using vi for editing, for example
Switch to insert mode,
Enter text into the work buffer, for example:
vi poems
i
Mary had a little lamb,
A little cheese,
A little ham.
Burp!
Press escape to get back into the command mode
Enter the write command
Leave the editor
Reopen the file using vi
Switch into command mode
Use the arrow keys to move the cursor
Use the alternative cursor control keys to move the cursor
Replace text: move the cursor to B in Burp! then type
Now type
Return to command mode
Save and exit the editor
Reopen the file using vi
Move the cursor, to the bottom of the file
Append text:
Now type the following lines:
Escape
:w (enter)
:q (enter)
vi poems
Escape
h,j,k,l
R
Delicious!
Escape
:wq (enter)
a
Mary had a polar bear
Whose fur was white as snow,
And everywhere that big bear went
The people
Let it go.
Return to command mode
Save the file but do not exit
Move the cursor to the beginning of the line "The people"
Join two lines together
Quit without saving the file
Go back into vi
Move the cursor to the M in Mary
Delete the letter M
Insert, the letter G
Move the cursor to the y in Mary
Replace with the letter p. goes back into command mode
Move to the next line, and delete it
Undo your changes
Exit without saving
Escape
:w
J
:q!
vi poems
x
iG escape
rp
dd
u
:q!
Download