legacy-dotfiles/emacs.d/nxhtml/etc/viper-tut/1basics
Tom Willemsen 94d2fc1815 Django, org
* Added nxhtml, mostly for django support.

  * Changed some org settings.
2011-03-07 09:04:49 +01:00

187 lines
6.4 KiB
Text

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.