The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please take a moment to review the Statement of Support.

READ ME FIRST

The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please take a moment to review the Statement of Support.

Instructions

Opening a file in vi

This first line is just to simply open a file with vi:

vi filename

The following command is used to recover a file that was being edited when the system crashed:

vi -r filename

The next command will open a file as read-only:

view filename

To find a line in vi

You can use the following to go to the last line in the file:

G

To go the the first line of the file, you can use the following:

1G

To move around in the editor

type h to type move the cursor to the left

type l to move it to the right

type k to move up

type j to move down

To search within vi

To search for text in vi, you can use the "/" key followed by your search term. This example uses mttext:

/ mttext

To exit vi

To quit and not save changes, you can use:

:q!

If you want to quit and save changes, you can use the following command:

:x!

TIP:

The above examples only hint at the power of vi. It is very popular amongst developers/administrators for good reason. We strongly suggest making backups of any files before experimenting with vi, in case you need to revert your changes.