Vim Sheet

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

VI/VIM Cheat Sheet

General format for commands Text Creation Copying Text

vi [n]operator[m]object a Append after cursor yy Yank entire line


ex :[address ]command[options ] i Insert before cursor [n]yy Yank n lines [n]
o Open line below yw Yank word
Invoking and exiting vi
O Open line above y$ Yank to end of line
$vi le Invoke vi <ESC> Exit text entry mode p Put after character
$view le Opens le in read-only mode P Put before character
:wq Write and quit Delete Text

:w Write x or [n]x Delete character ([n] Setting options

:w le Write to le characters) :set number Turn on line numbers


:w! le Overwrite existing le r[c ] Replace character with [c ] :set nonumber Turn o line numbers
:q Quit dd or [n]dd Delete current line (or [n] :set list Display tabs and end
lines) of lines
:q! Force quit
dw Delete word :set nolist Turn o list
d$ Delete to end of line :set showmode Indicate input mode
Display Text (CTRL+<character>)
u Undo last editing command :set noshowmode Turn o showmode
d Scroll down
:set wm=10 Dene automatic
u Page forward right margin
Searching
f Page forward :set wm=0 Turn o wm
/[string ] Escape following character
b Page backward
?[string ] Begin literal sequence Remove semicolon for usage in ~/.vimrc
n Next match
Cursor Movement
N Previous match Multiple Input Windows
<RIGHT>, Next character
:vsplit le Open another le
<SP>, or l
vertically
Change Text
<LEFT>, Previous character
:split le Open another le
<BS>, or h [n]s[string ] Substitute [n] characters
horizontally
<DOWN> or Character below with [string ]
<CTRL>+w Switch active window
j cc[string ] Change line with[string ]
:[cmd ] Run [cmd ] in active
<UP> or k Character above [n]cc[string ] Change [n] lines with
window
<RET> Beginning of line [string ]
- Beginning of previous line cw[string ] Change word to [string ]
c$[string ] Change end of line to Miscellaneous
G Go to last line
[string ] xp Transpose 2 characters
:[n] Go to line number [n]
[n]J Join [textitn] lines :r le Read le into buer
$ End of line
r<RET> Split line :![cmd ]% Run shell command [cmd ]
w or [n]w Forward beginning of
:%s/[string ] Substitute [string] with on current le
word ([n] words)
/[newstring ] [newstring] <CTRL>+l Redraw screen
e or [n]e End of word ([n] words) /g $vi -r le Recovery
b or [n]b Back beginning of word
([n] words)

You might also like