VIM cheatsheet

👋 FYI, this note is over 6 months old. Some of the content may be out of date.
On this page

Cheatsheets Jump to heading

Substitute or Find/Replace Jump to heading

To find each occurrence of ‘pick’ in the current line only, and replace it with ‘s’, enter (first press Esc key and type):

:%s/pick/s/g

To find and replace all occurrences of ‘pick’ with ‘s’, enter:

:%s/pick/s/g

To find and replace all occurrences of ‘pick’ with ‘s’, but ask for confirmation first, enter:

:%s/pick/s/gc

To find and replace all occurrences of case insensitive ‘eth1’ with ‘br1’, enter:

:%s/eth1/br1/gi

The above example will find eth1, ETH1, eTh1, ETh1 and so on and replace with br1. To find and replace all occurrences of ‘eth1’ with ‘br1’ for lines from 3 to 7, enter:

:3,7s/eth1/br1/g

← Back home