Linux Tutorials, Linux howto's and guides

Main menu

vi is a text based editor used on most Linux distributions and to run it you simply type viin the console. Initially you may fine vi a little confusing especially if your comparing it to desktop word processing software however after a little time you will grow to find it quick, simple and very efficient to use.

vi (pronounced vee eye) stands for ‘vi’sual editor it shows you’re the file you are editing but its’ important to remember that’s vi is a text editor and not a WYSIWYG editor like Microsoft word or openoffice writer. As it’s just for editing text it has all the functions you would expect such as insert, edit, delete but leaves our common formatting such as justification and indentation.

This howto vi gives you a simple overview of the following:

Creating a new file

Opening and closing a file

Moving around in a file

Baisc editing

Creating a new file with vi

To create a new file in vi is simple, let’s say you’re in your user’s home folder (/home/user/) simply type the follwoing at the consile:

vi newfile

You are now editing the file /home/user/newile simple isn’t it :). Also if you wanted to create a file in a different location simply give vi the path:

vi /path/to/newfile

To open an exsisting file:

vi filename

And again if you are not in the directory where the file is located then simply include the path to the fileL:

vi /path/to/filename

ok lets now look at using vi, create a new file called “howtovi”:

vi howtovi

Now you will see a blank file with blank lines, each will have a tilde (~) on the left, and status line is displayed at the bottom of the new file:

Insert mode
The letters you type display on the screen as letters and words.

How to Enter Text

To add soem text in the new file “howtovi” you will need to enter insert mode forst of all so pess the “i” key. It’s important to note that vi starts up in command mode. You will notice now that it now says — INSERT — on the status line (bottom right).

Now try and add some content, simply type a few lines and press enter when you want a new line.