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]

Inserting

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)

Deleting

x           delete character under cursor

dd         delete line under cursor

dw        delete word under cursor

db         delete word before cursor

Leave a comment