Vim

#organize

  1. how to download
  2. vim cheatsheet

Useful commands

  • Comment out a chunk of code:
    Ctrl + V
    c
    #
    

Hotkeys

Exiting

CLI | Explanation ——–|————: :q | Close file :qa | Close all files :w | Save :wq / :x | Save and close file ZZ | Save and quit ZQ | Quit without
checking changes

Exiting insert mode

CLI | Explanation ——–|————: Esc / <C-[> |Exit insert mode <C-C> |Exit insert mode,
and abort current
command

Clipboard

CLI | Explanation ——–|————: x | Delete character dd | Delete line (Cut) yy | Yank line (Copy) p | Paste P | Paste before "*p / "+p | Paste from system clipboard "*y / "+y | Paste to system clipboard

Find & Replace

CLI | Explanation ——–|————: :%s/foo/bar/g | Replace foo with
bar in whole document

CLI | Explanation ——–|————: h j k l | Arrow keys <C-U> / <C-D> | Half-page
up/down <C-B> / <C-F> | Page
up/down

Words

CLI | Explanation ——–|————: b / w | Previous/next word ge / e | Previous/next end
of word

Line

CLI | Explanation ——–|————: 0 (zero) | Start of line ^ | Start of line (after whitespace) $ | End of line

Character

CLI | Explanation ——–|————: fc | Go forward to character c Fc | Go backward to character c

Document

CLI | Explanation ——–|————: gg | First line G | Last line :{number} | Go to line {number} {number}G | Go to line {number} {number}j | Go down {number} lines {number}k | Go up {number} lines

Window

CLI | Explanation ——–|————: zz | Center this line zt | Top this line zb | Bottom this line H | Move to top
of screen M | Move to middle
of screen L | Move to bottom
of screen

CLI | Explanation ——–|————: n | Next matching
search pattern N | Previous match * | Next whole word
under cursor # | Previous whole word
under cursor

Tab pages

CLI | Explanation ——–|————: :tabedit [file] | Edit file in
a new tab :tabfind [file] | Open file
if exists
in new tab :tabclose | Close current tab :tabs | List all tabs :tabfirst | Go to first tab :tablast | Go to last tab :tabn | Go to next tab :tabp | Go to previous tab

Editing

CLI | Explanation ——–|————: a | Append A | Append from end of line i | Insert o | Next line O | Previous line s | Delete char and insert S | Delete line and insert C | Delete until end of line and insert r | Replace one character R | Enter Replace mode u | Undo changes <C-R> | Redo changes

Visual mode

CLI | Explanation ——–|————: v | Enter visual mode V | Enter visual line mode <C-V> | Enter visual block mode

In visual mode

CLI | Explanation ——–|————: d / x | Delete selection s | Replace selection y | Yank selection (Copy)