Vim is an editor with a steep learning curve. This is a list of shortcuts that I have learnt and use regularly. It is by no means intended to be a comprehensive list and will continue to grow as I learn more.
h/j/k/l- left, down, up, right
gg- to start of file
G- to end of file
0- to start of line
$- to end of line
b- to beginning of word
w- to beginning of next word
e- to end of current or next word
ctrl-n- go down in list, turns out this works on various other software e.g. Chrome + Sublime autocomplete
ctrl-p- go down in list, turns out this works on various other software like Chrome + Sublime autocomplete
ctrl-d- move down half a screen
ctrl-u- move up half a screen
HML- high, middle, low, move cursor to this position of the screen to prevent hitting
:Ex- enter netrw
:ls- list all listed buffers
:bn- next buffer
:bd- delete buffer
:b- switch to certain buffer, can tab for autocompletion, can search too. Or use a number from
ctrl-w s- split horizontally.
ctrl-w v- split vertically.
ctrl-w h/j/k/l- move focus between windows
ctrl-w r- switch windows around (left <-> right)
ctrl-w =- Normalize all split sizes
:Vex- visual split create a new vertical window in netrw mode
:Vex!adds to RHS
/- to search. My vimrc settings allow for case-insenstive unless a capital letter is used
*- on a current word to use that as the search term
N/n- Go back and forward between the matches.
I don’t use tabs a whole lot, but sometimes I keep a reference file open in a seperate one.
:tabe- open new tab
:tabc- close tab
gt/gT- next/prev tab
y- yank (copy)
cib- change in brackets
yy- yank line
dd- delete line
vib- select in brackets
V- select by whole lines
v- select text
ctrl v- visual block, when wanting to operate on multiple lines at once (adding tabs, commenting out etc)
gd- Go to definition
ctrl t- Go back a defintion (pop the ‘go to’ off the stack)
:FZF- search for file. Select a file in the list to open in new buffer
- Graphical cheat sheet - 2006 so dated but looks comprehensive and is often referenced.
- Devhints cheat sheet - this website has a bunch of great software engineering cheatsheets and cuts throught the rubbish.
You may find my .vimrc settings file here: https://github.com/oliverbenns/dotfiles/blob/master/.vimrc.
Plugins are installed in the setup script of that dotfiles repository.