VI Cheat Sheet

General Commands:

To exit vi and save changes: ZZ   or  :wq

To exit vi without saving changes: :q!

To enter vi command mode: [esc]


r          replace character under cursor with next character typed

R         keep replacing character until [esc] is hit

i           insert before cursor

a          append after cursor

A          append at end of line

O          open line above cursor and enter append mode

:%s/original/replacement Replace original text with replacement text

:%s/original/replacement/g Replace all (/gc with confirmation)


x           delete character under cursor

dd         delete line under cursor

dw        delete word under cursor

db         delete word before cursor

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s