]> git.rkrishnan.org Git - .emacs.d.git/blob - emacs/nxhtml/etc/viper-tut/1basics
remove toolbar and menubar
[.emacs.d.git] / emacs / nxhtml / etc / viper-tut / 1basics
1 Viper tutorial #1: The Basics
2
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).
6
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.
9
10
11 BASIC CURSOR MOVEMENT
12 ---------------------
13 To move through the tutorial use C-d (control d) and C-u (control u).
14
15         C-d     Move DOWN one half-screen
16                 (depress the control key and type d)
17
18         C-u     Move UP one half-screen
19                 (depress the control key and type u)
20
21 * EMACS-NOTICE: C-u is normally used in Emacs for UNIVERSAL-ARGUMENT.
22   You can in most cases use DIGIT-ARGUMENT instead.
23
24 >>> Now type C-d (control d) and C-u (control u) to move down and back up.
25
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
28 tutorial.
29
30 To move the cursor line by line, or character by character, use the
31 four keys 'h', 'j', 'k', and 'l'.
32
33         'h'     Move left one character
34         'j'     Move down one line
35         'k'     Move up one line
36         'l'     Move right one character
37
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.
40
41                                        UP
42                 .......   .......   .......   .......
43                 :     :   :     :   :     :   :     :
44           LEFT  :  h  :   :  j  :   :  k  :   :  l  :  RIGHT
45                 :.....:   :.....:   :.....:   :.....:
46
47                            DOWN
48
49 >>> Now type  'j'  or  'k'  a few times to bring the cursor to this line.
50
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.
54
55 >>> Try moving past the bottom of the screen using  'j' . Notice how
56 >>> how the screen scrolls downward.
57
58 >>> Now practice using  'k'  to move up, and  'h'  to move left.
59
60
61 DELETION
62 --------
63 To delete characters and lines, use 'x' and 'd''d'.
64
65         'x'       X-OUT one character
66         'd''d'      DELETE one line
67
68 To undo your changes, use 'u'.
69
70         'u'       UNDO last change only
71
72 >>> Delete this SCRAP line. Move to this line with  'j' or 'k' , now type  'd''d' .
73 >>> Try undoing the deletion with  'u' .
74
75 >>> Move to this line and x-out the Y's with  'x' : "whY ask whY?"
76
77 >>> Try undoing the deletion with  'u' . Try typing  'u'  several times.
78 >>> Notice that  'u'  only undoes the last change.
79
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.
83
84 Here are more lines on which to practice deleting and undoing (use: 'd''d' 'x' 'u' )
85
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.
89
90
91 QUIT COMMANDS
92 -------------
93 (DO NOT QUIT the tutorial at this time.)
94
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
98 use  'Z''Z'  to quit.
99
100  :q!<RETURN>    QUIT without saving changes
101                 (type a colon, then the letter q, then an
102                 exclamation point, and press RETURN)
103
104         'Z''Z'      Exit and save any changes
105                 (type capital Z, twice)
106
107
108
109 INSERTION
110 ---------
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.
114
115         'o'       OPEN a line for inserting text
116         'i'       INSERT starting at the cursor
117
118         ESC     ESCAPE from insert mode
119
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.
123
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.
129
130 >>> Type the date below your phone number. To do this:
131 >>>     Open another line using  'o' .
132 >>>     Type the date and press ESC.
133
134 >>> Type  'u'  to undo the insertion.
135
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'.
138 >>>     Press  'i' .
139 >>>     Type the nickname, use DELETE or BACKSPACE to erase any typos.
140 >>>     Then press ESC.
141
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
147 screen.
148
149
150 SUMMARY
151 -------
152 These are the vi commands you should know after tutorial #1:
153
154         C-d     Move DOWN one half-screen
155                 (depress the control key and type d)
156
157         C-u     Move UP one half-screen
158                 (depress the control key and type u)
159
160         'h'       Move left one character
161         'j'       Move down one line
162         'k'       Move up one line
163         'l'       Move right one character
164
165         'd''d'      DELETE one line
166         'x'       X-OUT one character
167
168         'u'       UNDO last change
169
170  :q!<RETURN>    QUIT without saving changes
171                 (type a colon, then the letter q, then an
172                 exclamation point, and press RETURN)
173
174         'Z''Z'      Exit and save any changes
175                 (type capital Z, twice)
176
177         'o'       OPEN a line for inserting text
178         'i'       INSERT starting at the cursor
179
180         ESC     ESCAPE from insert mode
181
182
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.
186
187 Copyright (c) 1992 Jill Kliger and Wesley Craig.  All Rights Reserved.