1 Viper tutorial #1: The Basics
3 This lesson lasts 10-15 minutes and teaches simple editing. Lines
4 which begin with >>> mark exercises you should try. When you
5 want to exit this tutorial type 'Z''Z' (type capital Z, twice).
7 When you type commands in vi they do not appear on the screen. If the
8 letters you type unexpectedly appear on the screen, press the ESC key.
13 To move through the tutorial use C-d (control d) and C-u (control u).
15 C-d Move DOWN one half-screen
16 (depress the control key and type d)
18 C-u Move UP one half-screen
19 (depress the control key and type u)
21 * EMACS-NOTICE: C-u is normally used in Emacs for UNIVERSAL-ARGUMENT.
22 You can in most cases use DIGIT-ARGUMENT instead.
24 >>> Now type C-d (control d) and C-u (control u) to move down and back up.
26 When you are done reading a screen, you are expected to type C-d to move
27 down to the next screen. You must remember to type C-d throughout the
30 To move the cursor line by line, or character by character, use the
31 four keys 'h', 'j', 'k', and 'l'.
33 'h' Move left one character
34 'j' Move down one line
36 'l' Move right one character
38 You will notice that these keys are in a straight line on the
39 keyboard. Study the diagram below showing the function of h, j, k, l.
42 ....... ....... ....... .......
44 LEFT : h : : j : : k : : l : RIGHT
45 :.....: :.....: :.....: :.....:
49 >>> Now type 'j' or 'k' a few times to bring the cursor to this line.
51 >>> Try moving off the right end of a line using 'l' . Notice that
52 >>> vi will not allow you to move off the end of the line using 'l' .
53 >>> Likewise, you cannot use 'h' and 'l' on a blank line.
55 >>> Try moving past the bottom of the screen using 'j' . Notice how
56 >>> how the screen scrolls downward.
58 >>> Now practice using 'k' to move up, and 'h' to move left.
63 To delete characters and lines, use 'x' and 'd''d'.
65 'x' X-OUT one character
66 'd''d' DELETE one line
68 To undo your changes, use 'u'.
70 'u' UNDO last change only
72 >>> Delete this SCRAP line. Move to this line with 'j' or 'k' , now type 'd''d' .
73 >>> Try undoing the deletion with 'u' .
75 >>> Move to this line and x-out the Y's with 'x' : "whY ask whY?"
77 >>> Try undoing the deletion with 'u' . Try typing 'u' several times.
78 >>> Notice that 'u' only undoes the last change.
80 * EMACS-NOTICE: In Viper you can use the repeat command '.' (just a dot)
81 to undo more changes. This goes in both direction, ie undoing and
82 redoing. Typing just 'u' changes direction.
84 Here are more lines on which to practice deleting and undoing (use: 'd''d' 'x' 'u' )
86 Emacs is a nice creation. Emacs is a nice creation.
87 Emacs is a nice creation. Emacs is a nice creation.
88 Emacs is a nice creation. Emacs is a nice creation.
93 (DO NOT QUIT the tutorial at this time.)
95 To quit a file without saving any changes you have made (for instance,
96 with the 'd''d' or 'x' commands) use :q!<RETURN> . To quit and save your
97 changes, use 'Z''Z' . When you are editing your own files, you normally
100 :q!<RETURN> QUIT without saving changes
101 (type a colon, then the letter q, then an
102 exclamation point, and press RETURN)
104 'Z''Z' Exit and save any changes
105 (type capital Z, twice)
111 You enter insert mode with 'i' or 'o' . Anything you type during insert
112 mode appears on the screen. When you are done inserting, press ESC
113 to exit insert mode. Type C-[ (control [ ), if you do not have an ESC key.
115 'o' OPEN a line for inserting text
116 'i' INSERT starting at the cursor
118 ESC ESCAPE from insert mode
120 During insert mode, use your erase character (usually backspace or
121 delete) to delete mistakes. The characters you delete will remain on
122 the screen until you press ESC.
124 >>> Insert your name and phone number below the next blank line. To do this:
125 >>> Open a line below using 'o' .
126 >>> Type your first and last name. Press RETURN.
127 >>> Then type your phone number and press ESC.
128 >>> Use 'x' to erase part of your phone number.
130 >>> Type the date below your phone number. To do this:
131 >>> Open another line using 'o' .
132 >>> Type the date and press ESC.
134 >>> Type 'u' to undo the insertion.
136 >>> Insert a nickname between your first and last names, using 'i'. To do this:
137 >>> Move the cursor to the spot between your names using 'h', 'j', 'k', 'l'.
139 >>> Type the nickname, use DELETE or BACKSPACE to erase any typos.
142 On some computers, a line may be longer than the width of the screen.
143 This means that a very long line may appear to be two lines on the
144 screen. This happens when you keep typing without pressing RETURN at
145 the edge of the screen. To avoid any confusion when you're inserting
146 text, be sure to press RETURN before reaching the right edge of the
152 These are the vi commands you should know after tutorial #1:
154 C-d Move DOWN one half-screen
155 (depress the control key and type d)
157 C-u Move UP one half-screen
158 (depress the control key and type u)
160 'h' Move left one character
161 'j' Move down one line
163 'l' Move right one character
165 'd''d' DELETE one line
166 'x' X-OUT one character
170 :q!<RETURN> QUIT without saving changes
171 (type a colon, then the letter q, then an
172 exclamation point, and press RETURN)
174 'Z''Z' Exit and save any changes
175 (type capital Z, twice)
177 'o' OPEN a line for inserting text
178 'i' INSERT starting at the cursor
180 ESC ESCAPE from insert mode
183 You are now prepared to do simple editing on your own files. Practice
184 using vi for a few days. Then take the second vi tutorial to learn
185 more powerful and useful vi commands.
187 Copyright (c) 1992 Jill Kliger and Wesley Craig. All Rights Reserved.