Vim Commands Cheatsheet
vimEssential Vim/Neovim commands for developers.
Modes
EscDefault mode for navigation and commands; press Esc from any mode to return
EsciEnter insert mode at cursor position to type text
ivEnter visual mode to select text character by character
v:Enter command-line mode to execute Ex commands
:wMovement
hMove cursor one character left
jMove cursor one line down
kMove cursor one line up
lMove cursor one character right
wMove cursor to start of next word
bMove cursor to start of previous word
eMove cursor to end of current or next word
0Move cursor to beginning of line
$Move cursor to end of line
ggMove cursor to first line of file
GMove cursor to last line of file
Ctrl+dScroll down half a page
Ctrl+uScroll up half a page
{Move to previous paragraph or blank line
}Move to next paragraph or blank line
%Jump to matching bracket or parenthesis
Editing
iEnter insert mode before cursor
aEnter insert mode after cursor
oInsert new line below and enter insert mode
IEnter insert mode at first non-blank character of line
AEnter insert mode at end of line
OInsert new line above and enter insert mode
xDelete character under cursor
ddDelete entire current line
yyCopy entire current line to register
pPaste content after cursor or below current line
PPaste content before cursor or above current line
uUndo last change
Ctrl+rRedo last undone change
.Repeat the last editing command
Text Objects
dwDelete from cursor to start of next word
diwDelete entire word under cursor without surrounding spaces
da"Delete text including surrounding double quotes
di"Delete text inside double quotes without quotes
dt,Delete from cursor up to but not including specified character
dt,ci{Delete content inside curly braces and enter insert mode
ca[Delete content including square brackets and enter insert mode
yi(Copy text inside parentheses to register
ditDelete content inside HTML or XML tag
Visual Mode
vStart visual mode for character-wise selection
VStart visual mode for line-wise selection
Ctrl+vStart visual block mode for column selection
gvReselect the last visual selection
Search and Replace
/patternSearch forward for pattern
/function?patternSearch backward for pattern
?constnJump to next search match
NJump to previous search match
*Search forward for word under cursor
#Search backward for word under cursor
:%s/old/new/gReplace all occurrences of old with new in file
:%s/foo/bar/g:%s/old/new/gcReplace all with confirmation prompt for each match
:%s/foo/bar/gcFile Operations
:wWrite current buffer to file
:qQuit current window
:wqWrite file and quit
:q!Quit without saving changes
:e filenameOpen file for editing
:e index.js:vs filenameOpen file in vertical split window
:vs app.js:sp filenameOpen file in horizontal split window
:sp utils.jsMacros and Marks
qaStart recording macro into register a
qaqStop recording current macro
@aExecute macro stored in register a
@a@@Execute the last played macro again
maSet mark a at current cursor position
ma`aJump to exact position of mark a
`a'aJump to beginning of line containing mark a
'a:marksDisplay list of all current marks