Cogs and Levers A blog full of technical stuff

vim Tips

Getting the most out of vim is really about committing commonly used key stokes/patterns into muscle memory. Once you have the basics of these movements, your text editing experience becomes a lot more optimised and efficient.

This blog post is just an index of useful keystrokes that I use.

Misc. stuff

Key Description
g q Format selection to 80 columnns
g ? Format selection to rot 13
. Repeat the last action

Macros

Key Description
q <reg> Record a macro into a register
q Stop recording macro
@ <reg> Execute macro stored in register

Adding text

Key Description
i Insert at cursor
I Insert at start of line
a Append after cursor
A Append at end of line
o Open a new line below
O Open a new line above

Buffer management

Key Description
^W ^O Back to one window
:on Back to one window
:bd Delete buffer
:bp Previous buffer
:bn Next buffer
:buffers List buffers
:b Show current buffer name
:b<n> Navigate to buffer N
Key Description
h j k l Movement
w W Next word
b B Back word
e E Next word (to the end)
ge gE Back word (to the end)
0 Beginning of line
^ Non whitespace
$ End of line
G Bottom of file
gg Top of file
{ Paragraph above
} Paragraph below
^D Page down
^U Page up

Split management

Key Description
^W S Create a split
^W V Create a vertical split
^W h j k l Navigate around splits

NERDTree

Key Description
o Open in previous window
g o Preview
t Open in new tab
T Open in tab silently
i Open split
g i Preview split
s Open VSplit
g s Preview Split