Vim
Help
Show help instructions and commands
:helpOpen user manual index
:help user-manualNavigate to topic (see navigation below), position cursor inside |...| for topic filename and open
CTRL + ]Exit help manual
:qGeneral
Commands and actions are extended with modifiers and repeated using counts
<action><modifier>
<count><modifier>Modifiers can be combined with counts to duplicate the modified action
<action><count><modifier>Example: Delete three words (d delete action, 3 count, w word modifier)
d3wExample: Move forward three words (3 count, w word modifier)
3wNavigation
Move cursor Up / Down, Left / Right
j = Up
k = Down
h = Left
l = Right
h (Left) j (Up) k (Down) l (Right)Move by a number of lines or characters (eg. up 4 lines)
<count>j
4jMove cursor to top / middle / bottom (High / Middle / Bottom) of page
H
M
LGo to start of file
ggGo to end of file
GPage down / up (f = forward, b = back) and half page (d = down, u = up)
CTRL + f
CTRL + b
CTRL + d
CTRL + uGo to line number
<line> SHIFT + G
<line> gg
:<line> ENTERMove to start, start (whitespace) and end of line
^
0
$Move by word boundary to start of word forward / backward (delimiter / whole word)
w
W
b
BMove by word boundary to end of word (delimiter / whole word)
e
EEdit
Insert text under / after the cursor
i
aInsert text at the beginning / end of the current line
I
AInsert a line above / below and insert text
o
OInsert text at the end of the word
eaRepeat the last action or edit
.Join line below to the current one
JTranspose two letters (performs forward delete/cut then paste)
xpComplete current partial word based on existing word list (cycle through next / previous entries)
CTRL + N
CTRL + PDelete
Delete text in front / behind cursor
x
XDelete current line (also cuts text to clipboard)
ddDelete to beginning / end of current word or start of next word
db
de
dwDelete to start / end of line
d^
d$Apply modifier to delete command (eg. Delete three words)
d<modifier><command>
d3wChange
Change entire line (combines delete and insert)
ccChange a word to beginning / end or start of next work
cb
ce
cwDelete to start / end of line
c^
c$Change from the cursor to the end of the line
CDelete character / line at cursor and substitute text
s
SReplace a single character (without triggering insert mode)
r<character>Replace multiple characters in replace mode
R<type>Search
Search forward / backwards for text
/<search-string>
?<search-string>Next / previous search result
n
NNext / previous word under cursor
*
#Replace
Replace all instances of string old with string new in current file
:%s/old/new/gReplace all instances with per item confirmation
:%s/old/new/gcCut, Copy, Paste
Cut current line
ddCopy the current line
yyCopy to beginning / end of current word or start of next word
ye
yw
ybCopy to start / end of line
y^
y$Paste buffer after / before cursor
p
PPaste multiple instances of the copied text
<num>p
5pVisual Mode
Visual selection mode by character / line (to apply commands to)
v
VExit visual selection mode
ESCMove visual marker to opposite end of selection
oVisual section with block select
CTRL + vCut text visually marked
dCopy text visually marked (yank)
yReplace selected text
cUndo / Redo
Undo edits and changes
uRedo edits and changes
CTRL+RRevert last change to original state
USave / Quit
Save file
:wQuit vim (normal, without saving / no prompt)
:q
:q!Write and quit
:wqEditing Multiple Files
Edit a file in a new view/buffer (Tab key to display filenames in current directory)
:e <file-name>Go to next file (buffer next)
:bnext
:bnGo to previous file (buffer previous)
:bprev
:bpRemove file from editor view/buffer (buffer delete)
:bdOpen file in a new split view of the current window
:sp <file-name>Configuration
Enable / disable line numbers
:set number
:set nu
:set nonumber
:set number!
:set nonu
:set nu!Set editor to paste mode (to retain pasted formatting)
:set pasteSet highlight search results or disable highligh
:set hlsearch
:set nohlsearchSplit Windows
Split window horizontally
ctrl + wsSplit window vertically
ctrl + wvSwitch between windows
ctrl + wwQuit active window
ctrl + wqLast updated