initial commit
[emacs-init.git] / nxhtml / etc / viper-tut / 4inserting
1 Viper tutorial #4: Insertion Techniques
2
3 This lesson lasts 5-10 minutes.  This tutorial assumes full knowledge
4 of tutorial #1, and familiarity with tutorial #2.  Lines which begin
5 with  >>>  mark exercises you should try.  When you want to exit this
6 tutorial type  'Z''Z' .
7
8
9 SIMPLE INSERTION
10 ----------------
11 You spend most of your time in vi inserting text.  As you might expect,
12 there are several commands to begin insertion.
13
14         'o'       OPEN a line below the cursor
15         'O'       OPEN a line above the cursor
16
17         'i'       INSERT starting before the cursor
18         'I'       INSERT at the beginning of the line
19
20         'a'       APPEND starting after the cursor
21         'A'       APPEND at the end of the line
22
23 Remember to type ESC to leave insert mode.  If you don't have an ESC key
24 type  C-[ (control [ ).
25
26         ESC     ESCAPE from insert mode
27
28 >>>  Move the cursor to this line.  Type  'O'  , enter your name.  Press ESC.
29 >>>  Next type  'o'  , enter the date.  Press ESC.
30
31 Note that  'O'  opens the line above and puts you in insert mode,
32 while  'o'  opens the line below and also puts you in insert mode.
33
34 >>>  Type  'a'  on any line above, enter your name.  Press ESC.  Do the
35 >>>  same for  'A'.
36
37 >>>  Read the following.  Your goal is to take the sentence fragment below:
38
39         BROWN FOX  OVER THE SEVEN LAZY
40
41 >>>  and convert it to
42
43         THE QUICK BROWN FOX JUMPED OVER THE SEVEN LAZY DOGS.
44
45 >>>  To do this type:
46 >>>     'I'  to insert  THE QUICK  (then press ESC)
47 >>>     move the cursor to after the X in FOX
48 >>>     'a'  to insert  JUMPED   (then press ESC)
49 >>>     'A'  to insert  DOGS.  (then press ESC)
50 >>>  Now move to the sentence fragment and make the changes outlined above.
51
52
53 JOINING LINES
54 -------------
55 Often it is convenient to join two short lines into one line.  There
56 are several ways to do this.  The easiest is the  J  command.  Other
57 methods will be explored in tutorial #5.
58
59         'J'       JOIN two lines
60
61 >>>  Go to the first line in the block below.  Type J.  Type J again.
62
63         Example: NOW IS THE TIME
64         the walrus said
65         TO THINK OF MANY THINGS
66
67 In the event that joining lines creates a line which exceeds the width
68 of the screen, you can break the line by typing  i  and pressing RETURN.
69
70
71 SUBSTITUTING TEXT
72 -----------------
73 Substituting combines the delete command and the insert command into a
74 single step.
75
76         #'s'      SUBSTITUTE for # characters
77         #'S'      SUBSTITUTE for # whole lines
78
79
80 In order to substitute text you have to know how much text you want to
81 delete.  Consider the following examples:
82
83         '3''s'      SUBSTITUTE the next 3 characters for what will be typed
84         '7''s'      SUBSTITUTE the next 7 characters for what will be typed
85
86 >>>  Change the SAMPLE DEFINITION below.  To do this:
87 >>>     move the cursor to the T in TWO
88 >>>     type  '3's
89 >>>     type  FOUR  then press ESC
90
91      SAMPLE DEFINITION:  A string quartet is defined to be
92                          a group of TWO musicians.
93
94
95 REPLACING TEXT
96 --------------
97 The  'r'  and  'R'  commands allow you to directly type over existing text.
98
99         'r'       REPLACE character (NO need to press ESC)
100         'R'       enter over-type mode
101
102 >>>  Correct each of the TYPOs on the sample line below.  To do this:
103 >>>     move the cursor to the misspelled character
104 >>>     type  'r'
105 >>>     type  the correct character
106
107      SAMPLE: maintanence  conveniance  complience  applience  dilagent
108
109 >>>  Use the over-type command,  'R'  ,  on the sample line above.
110 >>>  Type  'R'  then type the name of a local restaurant.  Press ESC.
111
112
113 CHANGING TEXT
114 -------------
115 The change command combines insertion, deletion, and the movement
116 commands. (Recall that the movement commands were taught in tutorial
117 #2.)  Change is probably more useful than replace or substitute.  The
118 general form of the change command is:
119
120     'c'movement   CHANGE to where the movement command specifies
121
122 Consider the following examples:
123
124         'c''w'      CHANGE to the beginning of the next WORD
125         'c''$'      CHANGE to the end of the line
126         'c'')'      CHANGE to the beginning of the next sentence
127         'c''t'e     CHANGE 'TIL the next  e
128         'c''3''w'     CHANGE the next 3 WORDS
129         'c''c'      CHANGE a line (cc is a special case of the c command)
130         'c''}'      CHANGE to the end of the paragraph
131
132 >>>  Follow these steps:
133 >>>     1.  move to the desired location in the practice paragraph below
134 >>>     2.  type 'c''w'  (change to the beginning of the next WORD)
135 >>>     3.  type your name
136 >>>     4.  press ESC
137
138     PRACTICE here.  Now is the time for all good users to learn the
139     editor.  The quick red fox jumped over the seven lazy fish.  Now
140     is the time for all good users to learn the editor.  The quick
141     brown computer jumped over the seven lazy users.  END PRACTICE
142
143 >>>  Experiment by using a variety of options for step #2.  Try
144 >>>  out   'c''$'  'c'')'  'c''t'e  'c''3''w'  'c''c'  'c''}'   on the practice paragraph above.
145
146 Note that the change command follows the same pattern as the delete
147 and yank commands which were explored in tutorial #3.
148
149
150 SUMMARY
151 -------
152
153         'o'       OPEN a line below the cursor
154         'O'       OPEN a line above the cursor
155
156         'i'       INSERT starting before the cursor
157         'I'       INSERT at the beginning of the line
158
159         'a'       APPEND starting after the cursor
160         'A'       APPEND at the end of the line
161
162         ESC     ESCAPE from insert mode
163
164         'J'       JOIN two lines
165
166         #'s'      SUBSTITUTE for # characters
167         #'S'      SUBSTITUTE for # whole lines
168
169         'r'       REPLACE character (NO need to press ESC)
170         'R'       enter over-type mode
171
172     'c'movement   CHANGE to where the movement commands specifies
173                 (e.g.  'c''3''w'  'c''$'  'c''c' )
174
175
176 These commands should improve your ability to insert text efficiently.
177 The next tutorials deal with advanced commands and tricks which can
178 further speed up your editing.
179
180 Copyright (c) 1992 Jill Kliger and Wesley Craig.  All Rights Reserved.