Normal mode *********** The default mode. Move around. Cut copy paste Mode switch =========== In Insert / Visual / Command mode, press Escape to switch back to Normal mode Moves ===== Direction Next word {Char}acter --------- --------- ----------- up word backward find till left l w e b ---> f{char} t{char} h k end <--- F{char} T{char} j right down W.rd Ba Pattern / Next match n <-- Pattern ? Prev match N Perform n times =============== {num}actions example 5dw Insert mode *********** The mode that allows typing in file Mode switch =========== In Normal / Visual mode press c / i / a / o to switch to Insert mode change before after on next line c{move} i a o C I A O line before after on previous line end line line Perform n times =============== {num}actions example 5cw Visual mode *********** Select text Mode switch =========== To switch to Visual mode from Normal mode v{moves} V{moves} Ctrl + v{move} ,------ ,-----------. ,---. Selections in Selections in Selections in ----. '------ '-----------' block mode character mode line mode '---' ----' Operations ========== x y p cut yank put P Command mode ************ Write commands and execute Mode switch =========== In normal (or) visual mode press : and type commands. Then press Enter to execute and go back to normal mode Open, save, edit ================ Edit Write Quit --------------- --------------- --------------- e w q e! q! e filename w filename To discard changes add ! to command Commonly used ------------- Open by filename e filename Save to file w Save to file and quit wq Save to file and quit ZZ (no going back) Quit without saving q! Tabs ==== Open tab tabnew Previous tab tabp Move tab tabmove Next tab tabn Match and replace ================= %s/// Example: %s/Match/Scratch/gi Flags ----- global / all matches g case insensitive i Macros ****** start recording on 'a' qa stop recording q perform recording 'a' again @a vimrc ***** Vim can be configured with a .vimrc text file One of the default locations commonly used is ~/.vimrc Relative number =============== ----------------------------- | 3 Another line | | 2 Another line | | 1 Another line | |4 The line with the cursor | | 1 Another line | | 2 Another line | ----------------------------- To make vim show number on current line and relative number on other lines as above add to vimrc the line: set number relativenumber