Standing Cloud Knowledge Base

Vi Editor Cheat Sheet

Last Updated: Feb 07, 2013 05:26PM MST
There are two different modes of operation within vi:

The command mode and the insert mode.  

The following commands are issued while in the command mode.  

The insert mode will insert whatever text you type into the current file.  

To return to command mode from insert mode, hit the ESCape key.  
(Note: This is always a safe thing to do and you should get in to the practice of using ESCape quite a lot.) 

Editor commands preceded by ‘:’, ‘/’, or ‘?’ will appear in the lower left hand corner of the screen.
Other commands will not appear on the screen. 

A SENTENCE is defined to end at a ‘.’, ‘!’, or a ‘?’ which is followed by either the end of the line or two 
spaces.

A PARAGRAPH is defined to begin after each empty line.  
 
CRUISING AROUND DELETING TEXT
↑ or k move cursor up  
x delete current character 
↓ or j   move cursor down
nx delete next <n> characters 
→ or l   move cursor right  
dw delete current word 
← or h   move cursor left  
dd delete current line 
+  move cursor to next line  
ndd delete next <n> lines 
-  move cursor to previous line  
D delete to end of line 
%  go to matching parenthesis or bracket  
dG delete from current line to bottom 
0 or ^  go to the beginning of line    
$  go to end of line  
IN SEARCH OF TEXT
n|  go to column <n>  
/string search forward for <string> 
w  skip forward one word  
?string search backward for <string> 
b  skip backward one word  
n repeat last search command 
e  go to end of current word  
:n,m s/str1/str2/g  search from line <n> to line <m> for <str1>  
)  skip to next sentence   and replace with <str2> 
(  skip to previous sentence  :1,$ s/str1/str2/g search and replace all occurences of <str1>  
}  skip to next paragraph   with <str2> 
{  skip to previous paragraph    
nG  go to line <n>  
 
CUTTING AND PASTING
G  go to bottom  
yw yank a copy of the current word 
yb yank a copy of the previous word 
Y yank a copy of current line 
 
INSERTING TEXT
nY yank a copy of the next <n> lines 
a  append after cursor  
p put last yanked or deleted or changed text after cursor 
A  append after end of line  
P put last yanked or deleted or changed text before cursor
i  insert before cursor    
I  insert at beginning of line  
 
CORRECTING MISTAKES   
o  open new line below current line  
u undo last change 
O  open new line above current line  
U restore current line 
:e! re-edit current file without saving changes 
 
CHANGING TEXT     
rx  replace single character with <x>  
 
FILE MANIPULATION
Rtext  replace with <text>  
:x or :wq quit and save changes 
J  join next line with current line  
:q! quit without saving changes 
cwtext  change word to <text>  
:w name write entire file to <name> 
.  repeat last command (text change, delete, etc.)
:w name write (save) changes 
comments powered by Disqus

Cloud application marketplace and management platform



    Email Us

support@standingcloud.com
http://assets2.desk.com/
false
sc_tech_support
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete