vi

Text editor that is installed on POSIX-compliant systems.

Open file

vi file_name

Command mode

To enter command mode, press [ESC]. vi starts in this mode by default.

Count repeats the effect of the command

[count][command]

Delete current character

x

Delete current line

dd

Copy current line

yy

Paste clipboard

p

Change word (Esc)

cw

Display line numbers

:set number

Execute UNIX commands! Example with ls command

:!ls

Insert file after current line

:r file

Save file

:w

Save & quit

:wq

Quit

:q

Quit without saving

:q!

Enter Insert mode

Append after the cursor

a

Insert before the cursor

i

Open line below

o

Open line above

O

Search & replace (command mode)

Search

Type [ESC] then “n” for next occurrence

:s/searchme

Search & Replace

Replace one occurrence

:s/replaceme/newtext/

Replace every occurrence

:%s/replaceme/newtext/