LEARN AN EDITOR

As usual, if you have a problem, raise your hand.  When you are done,
come to the TA or instructor and make sure you have your completion
of the lab recorded.  Before you go, always log off your machine.


VI FOR LIFE

1.  Find secure shell and connect to hilton.cec.wustl.edu
	as cs100.

2.  You are going to enter the vi editor using the command

	vi yourname

	except that you will use your name instead of yourname.

	vi is a very nice editor.  You have to learn an editor
	if you want to use UNIX.  pico is too simple, emacs
	is too complex.  vi is just right.  It's also the
	original UNIX visual editor, and the one that best
	exemplifies the UNIX aesthetic.

	UNIX has modes.  You enter the INSERT mode by typing
	i.

	Now you can type as usual, and use the ENTER key to 
	generate new lines.

	I want you to type the name of a person on each line,
	then a colon, then three words that describe that person.

	Go ahead an let your typos remain in the text.
	You want to have errors so we have something to fix.

	When you are done, press ESC (the escape key).  That
	exits INSERT mode.

	Be careful not to type any other keys when you are in
	COMMAND mode, because each key designates a command,
	and you have no idea what the mapping of keys to commands
	is yet.

3.  Try type 1G (shift G).  This moves the cursor to the first line.
	Then type 10G.  That moves the cursor to the tenth line.
	G moves to the last line.

	Type o.  That's the open command which opens a new line
	underneath the current line, and puts you in INSERT mode.
	Add five more names and comments.  

	Press ESC to exit again.

	Do this three more times.  You should have thirty names by now
	and lots and lots of errors.

4.  vi people do not move around their file the way that people do
	who only know the arrow keys.  Vi people look where they
	want to go, then go there.  Let's say that you have the name
	Sahil in your file.  You want to move the cursor to Sahil?  Type /,
	then Sahil, i.e., /Sahil.  Then ENTER.

	This should move you right to Sahil.  Not the right Sahil?
	Type n, and it will go to the next occurrence of Sahil.  Try
	this for a few names.  When the cursor is on the S of 
	Sahil, you can type i, which puts you in insert mode.

	Type Evil, then ESC.  This will make "Evil Sahil".  Do this
	for a few names.  I'm sure you will make lots of mistakes.

	Try typing w a few times.  Do you see how the cursor moves
	forward a word at a time?  e moves to the end of the next word.

	fx finds the next occurrence of x in the line.  What?  Try
	fa, fb, fc, until you get what I mean.

	You now know how to move the cursor around the file.
	Congratulations, you will never accept the slow way
	of moving using arrow keys again.

5.  You can delete a word by using dw.  You can change a word using cw.
	Change all instance of Evil to Good.

6.  You can join two lines by typing J.  This joins the current line
	with the line below it.

	You can undo by typing u.

	You are now in a position to fix all of your typing errors.

	Do it.  Take each error in sequence.  Use a combination of / and f
	to move to the error.  Use cw to change the word so that it
	is correct.  Press ESC to leave the INSERT mode.

	This seems very slow at the moment, but like most things
	that help you go really fast, it can be slow going at first.

	Ever watch the space shuttle lift off?

7.  There is so much more to learn, but this is a good place to stop
	for your first vi lesson.
	 
	Your file should be perfect now.

	Show the TA.