Vim commands of note

Written by Mimi Flynn

25 February 2016

Lately, I decided to switch from trusty old Sublime Text 3 to Vim. Why?


:e! reload file


ctrl+w, v opens new panel vertically

ctrl+w, h opens new panel horizonally

ctrl+w, w switches to next panel


zo open

zc close

Folding documentation

Moving around a file

0 beginning of the line

^ first non-blank character in a line

G end of file

gg beggin of file

H top of the screen

M middle of the screen

L bottom of the screen

Moving around


dw deletes word

d$ deletes to the end of the line

d^ deletes to the beginning of the line

dit delete inside tag where cursor is located


caw change word

cas change sentence

cb< replace whole element

ci" change inside quote when inside quotes

A powerful vim command I never knew


:b 4 go to buffer #4

Search and Replace

:%s/foo/bar/g Find each occurrence of ‘foo’ (in all lines), and replace it with ‘bar’.

:s/foo/bar/g Find each occurrence of ‘foo’ (in the current line only), and replace it with ‘bar’.

:%s/foo/bar/gc Change each ‘foo’ to ‘bar’, but ask for confirmation first.

:%s/\<foo\>/bar/gc Change only whole words exactly matching ‘foo’ to ‘bar’; ask for confirmation.

Search and Replace


:marks list current marks

Setting a mark

m plus a letter to identify the mark so ma

Deleting marks

:delmarks a delete mark a

Jumping to a mark

'a jump to the first non blank character in the line at mark ‘a’

\a` jump to mark

Modifying content in a mark

d'a delete from current line to line of mark a

da` delete from current cursor position to position of mark a

c'a change text from current line to line of mark a


Plugin Specific Notes


fn+f5 refreshed buffer when search panel is open

Personal .*RC notes

cntrl+n Nerdtree