| Basic Command | Description |
|---|---|
| h, j, k, l ARROWS | Move cursor left, down, up, right (You can also use arrows) |
| H, M, L | Go to the first, middle and last line of current screen |
| ctrl+ [f, b] | Jump forward, backward one full screen |
| ctrl+ [d, u] | Jump down, up one half screen |
| w, b | Move word forward, backward |
| 0, $ | Jump to start, end of line |
| [f] [CHAR] | Find the first occurance of CHAR at the current line |
| i | Change to insert mode |
| o, O | Insert new line (below, above) and change to insert mode |
| I, A | Append at the (beginning, end) of the line |
| d | Delete |
| dd | Delete current line |
| r | replace |
| u | Undo |
| [ctrl r] | Redo |
| gg | Go to start of file |
| G | Go to end of file |
| (#N)gg | Go to line N |
| [ctrl f], [ctrl b] | Move (forward, backward) one full screen |
| yy | Copy current line |
| p | Paste current line |
| v | Start visual selection mode |
| V | Start linewise visual mode |
| [ctrl v] | Start block visual mode |
| [v][i][BRACKET] | Select text between bracket |
| [ctrl v][NAV][I][TEXT][ESC][j] | Add indentation |
| :w , :q, :wq | Save, quit, save and quit |
| :set number | Add line numbers |
| :set tabstop=4 | number of space characters that will be inserted when the tab key is pressed |
| :set shiftwidth=4 | Print out lines that matches the regular expression |
| :set ai | Auto indentation |
| :set expandtab | insert space characters whenever the tab key is pressed |
| :set ts=4 sw=4 expandtab ai | last 4 commands at once |
| /REGEX | Search for regular expression |
| %s/TEXT1/TEXT2/gi | Replace TEXT1 with TEXT2 through the entire file |
| Command | Description |
|---|---|
| :e FILE | edit a file in a new buffer |
| :ls | list all open buffers |
| :bd | Close buffer |
| :bn, :bp | Buffer (next, previous) |
| [ctrl ^] | Toggle between last opened 2 files |
| :b(#N) | Go to buffer with id N |
| Command | Description |
|---|---|
| :tabnew FILE | Open file in new tab |
| :tabn, :tabp | Move to (next, previous) tab |
| :tabc | Close tab |
| :tabo | Keep only current tab |
| (#N)gt | Go to tab N |
| Commands | Description |
|---|---|
| :vsplit | Vertical split window |
| :split | Horizontal split window |
| [ctrl + w] [c] | Close window |
| [ctrl + w] [w] | Move cursor to other window |
| [ctrl + w] [o] | Keep current window only |
| [ctrl + w] [ARROWS] | Move cursor to respective window |
| :Ex | Open file explorer |
| :Vex | Vertical split and open explorer |
| :Sex | Split and open explorer |
| Commands | Description |
|---|---|
| m<lowercase_letter> | Mark current line in a file |
| '<lowercase_letter> | Go to that line |
| y'<lowercase_letter> | Copy from the current position of the cursor to the marked line "a" |
| m<uppercase_letter> | Mark file |
| '<uppercase_letter> | Go to that file |
| Commands | Description |
|---|---|
| q<letter> | Start recording |
| q | Stop recording |
| @<letter> | Play |
| 29@<letter> | Play 29 times |
Create new session:
:mksession ~/stored_session.vim
Then later you can source that vim file and you'll have your old session back:
:source ~/stored_session.vim
or open vim with the -S option:
vim -S ~/stored_session.vim
Suspend running vim:
[ctrl + z]
Resume vim session:
fg