0% found this document useful (0 votes)
42 views1 page

Vi Command Cheat Sheet

Uploaded by

ajeesol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Vi Command Cheat Sheet

Uploaded by

ajeesol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Vi Command Cheat Sheet

Quittin Motion Buffers


:x Exit, saving changes h Move left Named buffers may be specified before any deletion, change, yank or put
:q Exit as long as there have been no changes j Move down command, The general prefix has the form "c where c is any lowercase
ZZ Exit and save changes if any have been made k Move up character. for example, "adw deletes a word into buffer a, It may
:q! Exit and ignore any changes I Move right thereafter be put back into text with an appropriate "ap.
w Move to next word
Insertino Text W Move to next blank delim ited word Markers
Insert before cursor b Move to the beginning of the word Named markers may be set on any line in a file. Any lower case leiter
Insert before line B Move to the beginning of blank delimited word ma be a marker name. Markers ma also be used as limits for ran es.
a Append after cursor e Move to the end of the word mc Set marker c on this line
A Append after line E Move to the end of blank delimited word 'c Go to beginning of marker cline.
o Open a new line after current line ( Move a sentence back 'c Go to first non-blank character of marker clin e.
o Open a new line before current line ) Move a sentence forward
Replace one character { Move a paragraph back Replace
R IReplace many characters } Move a paragraph forward The search and replace function is accomplished with the :s command. It
o Move to the beginning of the line is commonl used in combination with ran es or the: command below.
Deleting Text $ Move to the end of the line :sfpatternfstring/flags Replace pattern with string according to flags.
Almost all deletion commands are performed by G Move to the first line of the file g Flag - Replace all occurrences of pattern
t ing d followed by a motion, G Move to the last line of the file c Flag - Confirm replaces.
dw Delete word nG Move to nth line of the file & Repeat last :s command
x Delete character to the right of cursor :n Move to nth line of the file
X Delete character to the left of cursor fc Move forward to c Counts
D Delete to the end of the line Fc Move back to c
dd Delete current line H Move to top of screen Nearly every command may be preceded by a number that specifies how
:d Delete current line M Move to middle of screen many times it is to be performed. For example, 5dw will delete 5 words
L Move to button of screen
Yanking Text Ctrl+u Page up
Almost all yank commands are performed by typing Ctrl+d Page down Ranges
followed bv a motion. % Move to associated ( ), { }, [ 1 Ranges may precede most "colon" commands and cause them to be
y$IYank to the end of the line executed on a line or IinesJ'or example :3,7d would delete lines 3-7.
yy Yank the current line Search for strinas :n,m I Range Lines n-m
:y Yank the current line fstring Search forward for string Range - Current line
?string Search back for string :$ Range - Last line
Changing text n Search for next instance of string :'c Range - Marker c
The change command is a deletion command that N Search for previous instance of string :% Range - All lines in file
leaves the editor in insert mode, It is performed by :g/pattern/ Range - All lines that contain pattern
Ping c followed by a motion.
Other

m n
cw Change word
TOggle capital and lower-case
Files
C Change to the end of the line
J Join lines
:wfile Write to file
cc Change the whole line
. Repeat last text-changing command
:r file Read file in after line
u Undo last change
:n Go to next file
PuUi no text
U Undo all changes to line
:p Go to previous file
p
P
I
Put after the position or after the line

Put before the position or before the line

:e file Edit file


Based on http://www.lagmonster.org/docslvi.html !!program Replace line with output from program

You might also like