[NTLUG:Discuss] Terminal Text Editor Question

Fred James fredjame at concentric.net
Tue Jul 24 11:30:18 CDT 2001


A cheat sheet in vi can be quite extensive, but here is a start - enough
to get by, I think.

Jack Snodgrass wrote:
> 
> Maybe one of the 'vi' guys can give a cheat sheat for 'vi'
> He're one for pico. This covers the basics.
> .... (omitted)
-- 
...make every program a filter...
-------------- next part --------------
vi Editing Commands:

use: vi filename

Two modes: insert and command - default is command

(1) In and Out of Insert Mode:
i = insert before cursor
I = insert before beginning of line
a = insert after cursor
A = insert after end of line
o = open a new line below current line
O = open a new line above current line
<esc> = quit insert mode (returns to command mode)

(2) Saving and Quiting (from command mode)
:wq = write (save) file and quit vi
:w = write without quiting vi
:q = quit vi
:q! = quit vi without write (no save)
ZZ = same as :wq

(3) Cursor movement (in command mode)
h = move cursor left one character
l = move cursor right one character
j = move cursor down one character
k = move cursor up one character
H = move cursor up home possition
G = move cursor up last line in file
nG = move cursor up to line number n in file
w = move cursor forword one word
b = move cursor backward one word

(4) Copy, Delete, and Paste
yy = copy current line
yw = copy current word (from cursor to end of current word)
y$ = copy to end of line
dd = delete current line
dw = delete current word (from cursor to end of current word)
D = delete to end of line
dG = delete to end of File
x = delete the current character
(paste operations insert the contents of the last copy or delete)
p = if the last copy or delete was a word or character, acts like a(ppend) to paste
    if the last copy or delete was a line, acts like o(pen) to paste

(4) Changes
cw = change word (from current possition to end of word
ncw = change n words
r = change character - current character - replace with one character
    example: rt replaces current character with a t
s = replace current character with any number of characters until <eac>
ns = same as s except replace n character beginning at current character

(5) Other stuff
/string = search for string
n = find next occurence of string
N = n only go backwords
u = undo last edit command
. = repeat last edit command
j join next line to end of current line, separated by a space



More information about the Discuss mailing list