BigCalm AIX UNIX VI Help |
Overview | Moving | Edit Mode | EXing Out |
Yanking yer bits | Information Commands | Multipliers | Ex Bits |
Buffers | Korn Shell |
vi is rather strange as a word processor - it is different from almost any other text processor because it has two different modes - i.e. edit and control modes. Control mode allows moving,ex commands,and general editing commands - to enter control mode (you should be in control mode when you first enter vi) just press Escape. Edit mode allows entering of text - see section below on the different ways of entering edit mode. There's also some notes on command line options on the handycommands page
If you've never used vi before, use 'i' (insert text), 'a' (append text), 'R' (overwrite text), 'dd' (delete line), 'x' (delete char), 'u' (undo last change), ':q!' quit without saving, and 'ZZ' save and exit - and remember to press escape after every edit.
There's almost always more than one way to do it in vi - a close examination of people (like myself) who use vi a lot reveals great differences in how they edit a text document. (For example, I never use numbered or alphabetic buffers, but use mark references and temporary files instead). There are numerous vi clones on various operating systems, so that unix lovers can have their favourite text editor whatever OS they're using.
{ | Back a paragraph |
} | Forward a paragraph |
w | forward a word |
b | back a word |
' | moves to a marked character, e.g. 'a will move to mark a |
f<char> | moves to the next occurence of <char> |
^F/^D | page down |
^B/^U | page up |
^R | refresh |
0 | move to beginning of line |
$ | move to end of line |
<number> return | move down number of lines |
<number> uparrow | move up number of lines |
<number> left | move left number of chars |
<number> right | move right number of chars |
/text | search for text (n to repeat, N to repeat backwards) |
?text | search backwards for text |
:<number> | move to line number - also :$ - move to end |
n | repeat last search |
N | repeat last search backwards |
G | move to end |
<number>G | move to line number |
~ | change case of letters |
k | cursor up |
j | cursor down |
l | cursor right |
h | cursor left |
e | move to end of word (nearly the same as w) |
^E | Scroll the screen down without moving the cursor |
^Y | Scroll the screen up without moving the cursor |
PRESS ESCAPE AFTER EVERY EDIT!!!!!!
a | append text |
i | insert text |
R | overwrite text |
^[ (ESC) | exit to control mode **** VERY IMPORTANT **** |
o | insert line below cursor and enter edit mode |
O | insert line above cursor and enter edit mode |
cc | blanks line, and allows editing |
A | append at end of line |
s | substitute current char with characters |
. | repeat last edit |
cw | change word |
:wq | save and exit |
:q | exit |
:q! | force exit without saving |
:w | save |
:w! | forced write (if permissions are set wrong for example) |
:w <filename> | write to a different file |
:x | save and exit |
:r <filename> | read filename in at cursor point |
ZZ | save and exit |
:e! | start editing again from time of last write. |
:e <file> | edit new file |
:!<shell command> | execute shell command |
:!ksh | exit to shell. type 'exit' to return to vi |
dd | deletes a line (d<number><CR> deletes that number of lines + 1) |
D | deletes to the end of a line |
x | deletes a character |
y | yank, erm, 'y6' for example will yank the 7 lines following the cursor into a buffer (yy or Y yanks one line) , where it may then be 'p'ut (which is also a form of 'undo' if you accidentally wipe a line using 'dd') |
J | joins two lines together. ( There is a bug in AIX vi which can cause this to scroll down a page and put you in insert mode. Pain in the bum) |
m | mark, e.g. 'ma' will set a marker 'a', which can then be used by an 'ex' command. - e.g. to copy a part of the text out to a different file, place two marks, one at the beginning, and one at the end of the text you wish to save out, and use the command :'a,'b w filename |
p | put lines that have been yanked or deleted |
u | undo last change |
U | undo all recent changes on a line |
'a,'b w delme1 | From mark a to markb write to new file delme1 |
'a,'b w>> delme1 | From mark a to mark b append to file delme1 |
!!sh | will execute the current line as a command on the shell, and insert the result into the document (good command - to pull a list of a directory into vi, just insert a line somewhere that says 'ls' and when you've got the cursor on that line do !!sh |
^g | shows the file currently being edited and the current line |
Most vi commands accept multipliers - e.g.
10x | will delete 11 characters |
100>> | will move the next 100 lines one tab to the right |
9y<CR> | will yank 10 lines into the buffer |
79i=<ESC> | will insert 79 '=' signs |
50k | will move you 50 lines up |
c3w | will substitute the next three words for whatever you type |
Try:
'a | mark a (marked in vi using 'ma') |
$ | end of line or end of file (depending where used) |
1 | beginning of file |
^ | beginning of line |
\ | general escape char to print characters other than alphanumeric ones. e.g. the text ^"\ would become \^\"\\ |
The Korn shell can have some of the features of the vi editor put into it. Either do 'ksh -o vi' to change type of shell or 'set -o vi' if you are already using the korn shell. Then, the shell will function as normal, except when you press <escape>. e.g. Pressing <escape>k will bring up the previous command.
---------------- End of VIHelp file ----------------
28th September 2001 | Copyright Jonathan Daniel 2001 |