VI Basics

OK… so basically every unix box has VI on it… however so many people are confused about it. Here are some basics:

vi filename
loads you into a weird and wonderful world of editor, but you can’t type anything. You can scroll up and down using the arrow keys generally, or J to go down and K to go up. You can move the cursor using the right and left arrow keys, or l to move left, and h to move right.

When you want to INSERT text at the point of the cursor, hit i

when your done, hit [ESC]

if you want to Append to the end of the line hit A and [ESC] to exit

to find a specific match you can do [ESC] [ESC] to make sure your out of edit mode and then

/searchstring

after you’ve found one match you can hit /[ENTER] and it will find the next match

to Quit, hit [ESC] [ESC] to make sure your out of edit mode, and then
:q[ENTER]

if you want to write the file, hit [ESC] [ESC] :w[ENTER]

You can stack commands, so [ESC] [ESC] :wq[ENTER] will write and quit vi.

There are tons of VI commands, but I’ll add more later on :)

Leave a Comment