HELP:h[elp] keyword - open help for keywordK - open man page for word under the cursorEXITING:x or ZZ writes (only if changes are made) and quit the file:wq writes (even if no changes are made) and quit the file:q - quit (fails if there are unsaved changes):q! or ZQ - quit and throw away unsaved changesFILE OPERATIONS:wq or :x or ZZ - write (save) and quit:q - quit (fails if there are unsaved changes):q! or ZQ - quit and throw away unsaved changes:wq filename.ext - writes and saves a file with a given name:sav[eas] file - save file as:ter[minal] - open a terminal window:w - write (save) the file, but don't exit:w !sudo tee % - write out the current file using sudo:wqa - write (save) and quit on all tabs<aside>
💡 Tip Run vimtutor in a terminal to learn the first Vim commands.
</aside>
<aside> 💡 Writing a file modifies its timestamp
</aside>
CURSOR MOVEMENTh - move cursor leftj - move cursor downk - move cursor upl - move cursor rightQUICK MOVEMENT% - move to matching character (default supported pairs: '()', '{}', '[]' - use :h matchpairs in vim for more info)^ - 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 document5gg or 5G - go to line 5DECLARATION MOVEMENTgd - move to local declarationgD - move to global declarationCURSOR MOVEMENT RELATIVE TO SCREENH - move to top of screenM - move to middle of screenL - move to bottom of screenzz - center cursor on screenCONTENT MOVEMENTw - 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)ge - jump backwards to the end of a wordgE - jump backwards to the end of a word (words can contain punctuation)REPEAT MOVEMENT; - repeat previous f, t, F or T movement, - repeat previous f, t, F or T movement, backwardsOCURRENCE MOVEMENTfx - jump to next occurrence of character xtx - jump to before next occurrence of character xFx - jump to previous occurrence of character xTx - jump to after previous occurrence of character xSCREEN MOVEMENTCtrl + e - move screen down one line (without moving cursor)Ctrl + y - move screen up one line (without moving cursor)Ctrl + b - move back one full screenCtrl + f - move forward one full screenCtrl + d - move forward 1/2 a screenCtrl + u - move back 1/2 a screenPARAGRAPH MOVEMENT} - jump to next paragraph (or function/block, when editing code){ - jump to previous paragraph (or function/block, when editing code)<aside>
💡 Tip Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
</aside>
BASIC INSERTIONi - insert before the cursorI - insert at the beginning of the linea - insert (append) after the cursorA - insert (append) at the end of the lineNEWLINE INSERTIONCtrl + j - begin new line during insert modeAUTO-COMPLETE INSERTIONCtrl + n - insert (auto-complete) next match before the cursor during insert modeCtrl + p - insert (auto-complete) previous match before the cursor during insert modeEXIT INSERT MODEEsc - exit insert modeCtrl + c - exit insert modeCtrl + [ - exit insert mode<aside>
💡 Tip Instead of b or B one can also use ( or { respectively.
</aside>