this is my vim commands cheatsheet
h– move cursor leftj– move cursor downk– move cursor upl– move cursor rightH– move to top of screenM– move to middle of screenL– move to bottom of screenw– jump forwards to the start of a wordW– jump forwards to the start of a word (words can contain punctuation)e– jump forwards to the end of a wordE– jump forwards to the end of a word (words can contain punctuation)b– jump backwards to the start of a wordB– jump backwards to the start of a word (words can contain punctuation)0– jump to the start of the line^– jump to the first non-blank character of the line$– jump to the end of the lineg_– jump to the last non-blank character of the linegg– go to the first line of the documentG– go to the last line of the document5G– go to line 5fx– jump to next occurrence of character xtx– jump to before next occurrence of character xF<char>– jump to previous occurrence of character<char>on lineT<char>– jump just before previous occurrence of character<char>;– repeat lastf/F/t/T,– repeat lastf/F/t/Tin reverse}– jump to next paragraph or block{– jump to previous paragraph or blockzz– center cursor on screenCtrl + b– move back one full screenCtrl + f– move forward one full screenCtrl + d– move forward half a screenCtrl + u– move back half a screen|<n>– move to column<n>z.– center current linez<CR>– current line to top of screenz-– current line to bottom of screen<C-e>– scroll down by one line<C-y>– scroll up by one line[[– go to previous section/function]]– go to next section/function[]– go to end of previous section][– go to end of next section:n– go to line numbern
💡 Prefix a cursor movement command with a number to repeat it. Example:
4jmoves down 4 lines.
i– insert before cursorI– insert at beginning of linea– append after cursorA– append at end of lineo– open new line belowO– open new line aboveea– insert at end of wordCtrl + h– delete character before cursorCtrl + w– delete word before cursorCtrl + u– delete to beginning of lineCtrl + j– insert new lineCtrl + t– indent (shift right)Ctrl + d– de-indent (shift left)Ctrl + n– next match auto-completeCtrl + p– previous match auto-completeCtrl + rx– insert contents of registerxCtrl + ox– temporarily enter normal mode for one commandEsc– exit insert mode<C-r>{reg}– insert contents of register<C-o>{motion}– run Normal command while in Insert:startinsert– enter Insert mode from command line:stopinsert– exit Insert mode from command line<C-l>– clear and redraw screen
r– replace one characterR– enter replace modeJ– join line with line below (with space)gJ– join line with line below (no space)gwip– reflow paragraphg~– switch case up to motiongu– lowercase up to motiongU– uppercase up to motionguu– lowercase current linegUU– uppercase current lineg~~– toggle case of current linegE– end of previous WORDge– end of previous wordcc– change entire linec$orC– change to end of lineciw– change inner wordcw/ce– change word / to end of words– delete and substitute characterS– delete and substitute linexp– transpose charactersu– undoU– undo entire lineCtrl + r– redo.– repeat last command:norm– run Normal command across linesgq– format text
v– visual character modeV– visual line modeCtrl + v– visual block modeo– move to other end of selectionO– move to other corner of blockaw/ab/aB/at– around word / () / {} / tagsiw/ib/iB/it– inner word / () / {} / tagsEsc– exit visual mode>gv,<gv– reselect after indentingI,A– block insert / appendgq– format selected text
💡 Use
(or{in place ofborBfor text object movement.
>/<– shift right / lefty– yankd– delete~– switch caseu– lowercaseU– uppercase
:reg– list registers"xy– yank into registerx"xp– paste from registerx"ayy– yank current line into registera"+y,"+p– system clipboard (X11 clipboard)"*y,"*p– primary selection (X11 primary)
💡 Registers are saved in
~/.viminfoand persist across sessions.
"0– last yank"– unnamed register%– current filename#– alternate filename*– X11 primary+– X11 clipboard/– last search:– last command.– last inserted text-– last small delete=– expression_– black hole
:marks– show all marksma– set marka`a– go to markay\a` – yank to mark`0– previous Vim exit position`"– last editing position in file`.– last edit`` – last jump:ju[mps]– jump listCtrl + i– jump forwardCtrl + o– jump back:changes– change listg– next changeg;– previous changeCtrl + ]– jump to tag under cursor'[,']– start/end of last change/yank
💡 Use
'to jump to the start of a line,`to jump to exact position.
qa– start recording intoaq– stop recording@a– play macro froma@@– repeat last macro
yy,2y– yank 1 or 2 linesyw,yiw,yaw– yank word variantsy$orY– yank to end of linep,P– paste after/beforegp,gP– paste and leave cursor after textdd,2dd– delete linesdiw,daw– delete word variantsd$orD– delete to end of linex– delete character
>>,<<– shift line right/left>%– indent block>ib,>at– indent text object3==– re-indent 3 lines=%,=iB,gg=G– re-indent scopes]p– paste and match indentation
:w– save:w !sudo tee %– save with sudo:wq,:x,ZZ– save and quit:q– quit:q!,ZQ– force quit:wqa– save and quit all
/pattern,?pattern– search forward/backn,N– repeat search:%s/old/new/g– replace in whole file:%s/old/new/gc– replace with confirmation:noh[lsearch]– remove highlights/\cword,/\<word\>– smart word searches:vimgrep /pattern/ **/*.c– search across files:10,20s/old/new/g– range replace:'<,'>s/old/new/g– visual replace:.s/old/new/g– current line replace
za,zo,zc– toggle/open/close foldzr,zm,zi– fold more/less/toggle]c,[c– jump to next/prev change
💡 Use uppercase (e.g.,
zA) to apply folding recursively.