Editing files using VI editor.

JAVAERO – The vi editor is probably the only editor you will use in the unix command line. It is quite different from the ordinary editor you are familiar in windows. It will take time to get used to. However, when you have mastered it, you’re will be more efficient in your work.

To edit a file named poem.txt, invoke vi like this:

$ vi poem.txt

If the file poem.txt exists, vi will open the file for editing. If not, this will tell vi to create a new file named poem.txt.

Unlike our usual microsoft editors where you can begin typing your text, vi does not allow you to do that. When it is launched it is said to be in “command mode”. In this mode, vi will interpret your keystrokes as commands. These commands are usually what you see in the toolbar of our familiar editors. In vi, there is no toolbar. Commands are invoked using key strokes. In order to type any text at all, you need to be in the “edit” mode. You can do this by pressing the “i” key. This is a command that tell vi to be in the edit mode. Once in the edit mode, you can then start typing. Here is a nice unix poem you can type using vi.

Waka waka bang splat tick tick hash,
Caret quote back-tick dollar dollar dash,
Bang splat equal at dollar under-score,
Percent splat waka waka tilde number four,
Ampersand bracket bracket dot dot slash,
Vertical-bar curly-bracket comma comma CRASH.

One you are done entering the text, you go to the command mode using the escape key (ESC). In the command mode, you can save your text by typing “:wq”.

This is basic vi editing. other advance features we will learn as we progress.


Published by

Bobby Corpus

Is an IT Architect.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s