Understanding basic vi (visual editor)

Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs.

Vim behaves differently, depending on the name of the command (the executable may still be the same file).

vim The “normal” way, everything is default.

ex Start in Ex mode. Go to Normal mode with the “:vi” command. Can also be done with the “-e” argument.

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

vi file-name

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

vi -r file-name

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

vi ew file-name

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 buddy:

/buddy

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!

Reference : man vi command line

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.