Assignments

Start vi

vi vitest↵

You wil see something like


All actions start with a command, a letter, and they all end with pressing esc.

Now enter an i (insert), followed by This is an exercise in using 'vi'↵ I know that practice makes perfect.


Now press esc, and notice the difference on the screen.

Move the insertion marker, with the arrow keys, to the beginning of the word practice, and key in: imuch , a space at the end. What happened? Now press esc.

Move the insertion point somewhere else, and press u. What happened now?

Move to line 2, and enter Othis is a new line

Press esc, and check for the new line. Where is it?

Now press u

The cursor is still on line 2, now key othis is another new line

Press esc, and check for the new line. Where is it this time? What is the difference between O, and o?

Move the cursor to line 1 and enter: yy this will copy the line at the cursor. Now move the cursor to line 2, and press p, and finally move the cursor to the last line and press P.

What is the difference between P, and p? Will any of the work before yy has been done?

Move to line 2 and do dd. What was that? Your line disappeared, it was cut away. Would you venture a guess as to how to get it back? Yes, with a u

Delete it again. Then press p. What happened?

Move the cursor to the n of an in the first line. press x. What happened? Try x again, then p.

Move to the word know in line 2. The key in rt. What happened? Do a u. Now key in Rtest. Conclusion?

Press : (colon). The colon will appear at the bottom left of the screen. This is a prompt for ed commands. Try w, saving the file. w filename saves the file under the name filename. wq saves the file and quits vi. q! quits without saving.

If you quit the program, then restart and place the cursor on the n of in in line 1. First press x. Now watch when you press ai. What happened?

Press u and try the same thing again but with an ii where you did an ai before. The tell me what is the difference between the a, and the i commands.