VIM
First of a series of cheatsheets. The commands I actually reach for in Vim.
Commands
:help | manual |
vimtutor | vim tutorial |
:open <filename> | open file |
:Explore | navigate to or open other files |
i | insert mode |
< | > | indent or unindent line one level |
. | repeat last command |
R | replace mode |
b / w | move to previous or next word |
:save <name> | save file as |
:edit <filename> | edit file |
:vsplit | vs | C-w v | vertical split |
:hsplit | sp | C-w s | horizontal split |
C-w hjkl | change window |
C-w HJKL | move window to |
C-w +- <> | resize window |
C-w C-r | rotate windows |
:ls | show buffers |
:b <number> | change current buffer to |
:bn | :bp | move to next or previous buffer |
:close <current or buffer-number> | close buffer |
:set mouse=a | enable mouse functionality |
:terminal | open terminal |
:set number | show line numbers |
:54 | move to line 54 |
ggVG | select all lines |
u | undo |
Ctrl-r | redo |
tabnew <name> | new tab |
gt | switch between tabs |
shift+v | select line |
ctrl+v | block select |
y | yank selected block or lines |
p | paste lines that you yanked before |
d | x | delete/cut selected block |
o | create new line below and move to insert mode |
O | create new line above and move to insert mode |
:syntax on|off | enable or disable syntax highlighter |
mks | mks! <name.vim> | make session file |
vim -S | :so session.vim | open session file |
:scrollbind | scroll same in all panes |
:set noscrollbind | :tabdo windo set noscrollbind | disable scrollbind |
ctrl+- | zoom out |
ctrl+shift++ | zoom in |
:colorschema retrobox | set colorscheme |
:set filetype=<extension|html> | set filetype |
:X | -x <filename> | encrypt file |
set key= | disable encryption |
0 | jump to start of line |
$ | jump to end of line |
gg | go to first line |
G | go to last line |
:w !sudo tee % | save readonly file |
~/.vimrc | make your configuration persistent by writing it here |
:cd %:p:h | change vim dir to current dir |
Vimdiff
shift+v — select lines that you want to change,
then type :diffget or :diffput to make changes.
Run :diffupdate to refresh the page.
Websites
Plugins
- vim-plug
- vim-windowswap
- nerdtree
- coc.nvim
- vim-gitgutter
- vim-startify
- vim-multiple-cursors