vi cheatsheet

Get the PDF here.

The bare minimum vi.

How to open a new or existing file in vi

vi filename

File navigation

Use [Page Up] , [Page Down]  to page through the file. Use the arrow keys to move the cursor.

Command mode and insert mode

When you first start vi, you are in command mode

To switch to insert mode


Once in insert mode, you can type in your text file.

To switch from insert mode to command mode


Command mode

Quit without saving changes




Write (save)


Write a copy of the file to another name

:w filename

Search for a string (replace “search” with the string you are searching for)


Global search and replace (replace “search” and “replace” with the strings you are searching and replacing)


Leave a Reply

Your email address will not be published. Required fields are marked *