summaryrefslogtreecommitdiffstats
path: root/emacs.d/nxhtml/etc/viper-tut/1basics
blob: aea1fc561fbc32c9a9feabbcb7bc8fee929ac357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Viper tutorial #1: The Basics

This lesson lasts 10-15 minutes and teaches simple editing.  Lines
which begin with  >>>  mark exercises you should try.  When you
want to exit this tutorial type  'Z''Z'  (type capital Z, twice).

When you type commands in vi they do not appear on the screen.  If the
letters you type unexpectedly appear on the screen, press the ESC key.


BASIC CURSOR MOVEMENT
---------------------
To move through the tutorial use C-d (control d) and C-u (control u).

        C-d     Move DOWN one half-screen
                (depress the control key and type d)

        C-u     Move UP one half-screen
                (depress the control key and type u)

* EMACS-NOTICE: C-u is normally used in Emacs for UNIVERSAL-ARGUMENT.
  You can in most cases use DIGIT-ARGUMENT instead.

>>> Now type C-d (control d) and C-u (control u) to move down and back up.

When you are done reading a screen, you are expected to type C-d to move
down to the next screen.  You must remember to type C-d throughout the
tutorial.

To move the cursor line by line, or character by character, use the
four keys 'h', 'j', 'k', and 'l'.

        'h'     Move left one character
        'j'     Move down one line
        'k'     Move up one line
        'l'     Move right one character

You will notice that these keys are in a straight line on the
keyboard.  Study the diagram below showing the function of h, j, k, l.

                                       UP
                .......   .......   .......   .......
                :     :   :     :   :     :   :     :
          LEFT  :  h  :   :  j  :   :  k  :   :  l  :  RIGHT
                :.....:   :.....:   :.....:   :.....:

                           DOWN

>>> Now type  'j'  or  'k'  a few times to bring the cursor to this line.

>>> Try moving off the right end of a line using  'l' .  Notice that
>>> vi will not allow you to move off the end of the line using  'l' .
>>> Likewise, you cannot use  'h'  and  'l'  on a blank line.

>>> Try moving past the bottom of the screen using  'j' . Notice how
>>> how the screen scrolls downward.

>>> Now practice using  'k'  to move up, and  'h'  to move left.


DELETION
--------
To delete characters and lines, use 'x' and 'd''d'.

        'x'       X-OUT one character
        'd''d'      DELETE one line

To undo your changes, use 'u'.

        'u'       UNDO last change only

>>> Delete this SCRAP line. Move to this line with  'j' or 'k' , now type  'd''d' .
>>> Try undoing the deletion with  'u' .

>>> Move to this line and x-out the Y's with  'x' : "whY ask whY?"

>>> Try undoing the deletion with  'u' . Try typing  'u'  several times.
>>> Notice that  'u'  only undoes the last change.

* EMACS-NOTICE: In Viper you can use the repeat command '.' (just a dot)
  to undo more changes.  This goes in both direction, ie undoing and
  redoing. Typing just 'u' changes direction.

Here are more lines on which to practice deleting and undoing (use: 'd''d' 'x' 'u' )

        Emacs is a nice creation. Emacs is a nice creation.
        Emacs is a nice creation. Emacs is a nice creation.
        Emacs is a nice creation. Emacs is a nice creation.


QUIT COMMANDS
-------------
(DO NOT QUIT the tutorial at this time.)

To quit a file without saving any changes you have made (for instance,
with the  'd''d'  or  'x'  commands) use  :q!<RETURN> . To quit and save your
changes, use  'Z''Z' .  When you are editing your own files, you normally
use  'Z''Z'  to quit.

 :q!<RETURN>    QUIT without saving changes
                (type a colon, then the letter q, then an
                exclamation point, and press RETURN)

        'Z''Z'      Exit and save any changes
                (type capital Z, twice)



INSERTION
---------
You enter insert mode with  'i'  or  'o' . Anything you type during insert
mode appears on the screen.  When you are done inserting, press ESC
to exit insert mode.  Type  C-[ (control [ ), if you do not have an ESC key.

        'o'       OPEN a line for inserting text
        'i'       INSERT starting at the cursor

        ESC     ESCAPE from insert mode

During insert mode, use your erase character (usually backspace or
delete) to delete mistakes. The characters you delete will remain on
the screen until you press ESC.

>>> Insert your name and phone number below the next blank line. To do this:
>>>     Open a line below using  'o' .
>>>     Type your first and last name. Press RETURN.
>>>     Then type your phone number and press ESC.
>>>     Use  'x'  to erase part of your phone number.

>>> Type the date below your phone number. To do this:
>>>     Open another line using  'o' .
>>>     Type the date and press ESC.

>>> Type  'u'  to undo the insertion.

>>> Insert a nickname between your first and last names, using 'i'. To do this:
>>>     Move the cursor to the spot between your names using  'h', 'j', 'k', 'l'.
>>>     Press  'i' .
>>>     Type the nickname, use DELETE or BACKSPACE to erase any typos.
>>>     Then press ESC.

On some computers, a line may be longer than the width of the screen.
This means that a very long line may appear to be two lines on the
screen.  This happens when you keep typing without pressing RETURN at
the edge of the screen. To avoid any confusion when you're inserting
text, be sure to press RETURN before reaching the right edge of the
screen.


SUMMARY
-------
These are the vi commands you should know after tutorial #1:

        C-d     Move DOWN one half-screen
                (depress the control key and type d)

        C-u     Move UP one half-screen
                (depress the control key and type u)

        'h'       Move left one character
        'j'       Move down one line
        'k'       Move up one line
        'l'       Move right one character

        'd''d'      DELETE one line
        'x'       X-OUT one character

        'u'       UNDO last change

 :q!<RETURN>    QUIT without saving changes
                (type a colon, then the letter q, then an
                exclamation point, and press RETURN)

        'Z''Z'      Exit and save any changes
                (type capital Z, twice)

        'o'       OPEN a line for inserting text
        'i'       INSERT starting at the cursor

        ESC     ESCAPE from insert mode


You are now prepared to do simple editing on your own files.  Practice
using vi for a few days.  Then take the second vi tutorial to learn
more powerful and useful vi commands.

Copyright (c) 1992 Jill Kliger and Wesley Craig.  All Rights Reserved.