University of Colorado at Boulder    
Map A to Z Index Search CU Home
ITS logo
Information Technology Services News | ITS Search
ITS Docs
 

vi Commands

 

Window motions

<CTRL>d -- Scroll down (half a screen)
<CTRL> -- Scroll up (half a screen)
<CTRL>f -- Page forward
<CTRL>b -- Page backward
/string -- Search forward
?string -- Search backward
n -- Repeat search
N -- Repeat search reverse
G -- Go to last line
nG -- Go to line n :n -- Go to line n
<CTRL>l -- Redraw screen
<CTRL>g -- File information


Cursor motions

H -- Upper left corner (home)
M -- Middle line
L -- Lower left corner
h -- Back a character
j -- Down a line
k -- Up a line
^ -- Beginning of line
$ -- End of line
l -- Forward a character
w -- Forward one word
b -- Back one word
fc -- Find c
; -- Repeat find (find next c)


Input commands (end with ESC)

a -- Append after cursor
i -- Insert before cursor
o -- Open line below
O -- Open line above
:r file -- Insert file after current line


Changes during insert mode

 

<CTRL>h -- Back one character
<CTRL>w -- Back one word
<CRTL>u -- Back to beginning of insert

 

 


Move text from file old to file new

vi old "a10yy -- Yank 10 lines to buffer a
:w -- Write work buffer
:enew -- Edit new file
"ap -- Put text from a after cursor

 


Deletion commands

dd -- Delete line
ndd -- Delete n lines to general buffer
dw -- Delete word to general buffer
ndw -- Delete n words
d) -- Delete to end of sentence
db -- Delete previous word
D -- Delete to end of line
x -- Delete character

 


Recovering deletions

p -- Put general buffer after cursor
P -- Put general buffer before cursor


Change commands

s -- Substitute (ESC) - 1 char with string
cw -- Change word (ESC)
cc -- Change line (ESC) - blanks line
c$ -- Change to end of line
rc -- Replace character with c
R -- Replace (ESC) - typeover
. -- Repeat last change

 


Undo commands

u -- Undo last change
U -- Undo all changes on line

 


Rearrangement commands

yy or Y -- Yank (copy) line to general buffer
"z6yy -- Yank 6 lines to buffer z
yw -- Yank word to general buffer
"a9dd -- Delete 9 lines to buffer a
"A9dd -- Delete 9 lines; append to buffer a
"ap -- Put text from buffer a after cursor
p -- Put general buffer after cursor
P -- Put general buffer before cursor
J -- Join lines

 


File management commands

:w name -- Write edit buffer to file name
:wq -- Write to file and quit
:q! -- Quit without saving changes
ZZ -- Same as :wq
:sh -- Execute shell commands (<CTRL>d)

 


Parameters

:set list -- Show invisible characters
:set nolist -- Don't show invisible characters
:set number -- Show line numbers
:set nonumber -- Don't show line numbers

 

Return to Top of Page

 

Getting Help
IT Service Center
(303) 735-HELP
help@colorado.edu

 

Search by Topic

 

Did this document help you?
yes    no

How can it be improved?

       
       Support | Training | Facilities | About ITS | ITS Home
 

Last reviewed: September 30, 2003

itsfeedback@colorado.edu  | Policies | Privacy
© 2000
The Regents of the University of Colorado