vim.md

Vim #

A modal editor: keys do different things depending on the mode. Press Esc to return to Normal mode, where most commands live. Commands compose, so a count and a motion combine: 3dw deletes three words.

Modes #

KeyMode
EscBack to Normal mode
i aInsert before / after the cursor
I AInsert at line start / end
o OOpen a new line below / above
v VVisual (character / line) select
Ctrl-vVisual block select
:Command-line mode

Motions #

KeyMoves to
h j k lLeft, down, up, right
w b eNext word, back a word, end of word
0 ^ $Line start, first non-blank, line end
gg GFirst line, last line
{ }Previous / next paragraph
Ctrl-d Ctrl-uHalf page down / up
%Matching bracket
f x t xJump to / before next x on the line

Editing #

KeyAction
x rDelete char / replace one char
dd yy pDelete line, yank line, paste
dw cwDelete / change a word
d$ c$Delete / change to end of line
ciw ci"Change inner word / inside quotes
>> <<Indent / outdent the line
u Ctrl-rUndo / redo
.Repeat the last change
JJoin the next line up

Search & replace #

/pattern        search forward      ?pattern   search backward
n   N           next / previous match
*   #           search word under the cursor

:%s/old/new/g       replace all in the file
:%s/old/new/gc      ... with confirmation per match
:s/old/new/g        replace all on the current line
:noh                clear search highlight

Buffers, windows, tabs #

:e file         open a file        :w   write     :q   quit    :wq  write+quit
:bn  :bp        next / prev buffer        :ls       list buffers
:sp  :vsp       split horizontal / vertical
Ctrl-w h/j/k/l  move between splits        Ctrl-w q  close split
:tabnew         new tab           gt  gT   next / prev tab

Survival #

KeyAction
:q!Quit without saving
ZZSave and quit
:w !sudo tee %Save a file you opened without sudo
q:Open the command history window
:help xHelp for command x
gg=GRe-indent the whole file
Ctrl-o Ctrl-iJump to older / newer cursor position

© 2026 anguishedturtle.comBit Night RunnerSupportPrivacy