How to edit in VI

UNIX has its own editor dubbed as “vi”. This editor is available in all Unix operating systems; hpux, bsd, aix, solaris and many others. This editor can be operated in two different modes viz. insert mode and the default mode which is known as command mode. Command mode is the default mode of the vi editor. When you open a file, it is available for you in the command or default mode. However, all the changes that you make will be treated as vi commands. In vi mode, you will not be able to see any words on the screen which you are typing. In command mode, you can give different commands to the computer.

How to edit in vi in command mode
How to edit in VI
The simple commands to edit in vi are as follows;

a Shifts to insert mode
h Cursor moves to one left
i Shift to the insert mode
j Cursor moves down to one line
k Cursor moves up to one line
l Cursor moves one position to right
r One character is replaced under the cursor.
u Undo. Again if you give the same command, the changes will re-do.
x Delete

How to edit in vi in insert mode

Insert mode is another mode that is available when you want to edit in vi editor. For entering any text in a file opened in insert mode, you need to press “a” or “i”. This will insert the text in vi and you will see the words which your are typing on the screen. If you want to switch from insert mode to command mode, ESC key is used.

For editing “vi” in your computer, VI editor will be the most powerful software. You can edit all the files as well as create new files using this editor. It is easy to start the vi editor. You only need to type vi and the filename. You can also open or start the editor without any filename. But later on after the editing process is over, you won’t be able to save the file and at this time you will have to give some file name to the file. When you open the VI editor, you will see tildes (~) all over on the left hand side of the screen. At the bottom there is a place to put the filename so that you can open it for editing. Now, when you have to get out of the VI editor, two modes are available. It is necessary that you should be in the command mode. Press the “Esc” button to exit to shuffle to the command mode. To quite from VI editor, you need to give the command. The command for quitting is “:q”. You will be asked to save all the changes made in all files before quitting the editor. To save all the edited files, “:w” will be the command.

Other commands in VI editor are as follows;

d^ Delete all the characters from the beginning of the line till the position of cursor
d$ Delete all the characters from the end of the line till the position of cursor
dw Delete the word from the cursor position
3dd Deletes 3 lines from the position of the cursor.
^ Starting point of a line
. Single character matching
* Matches with the previous characters
$ Ending of a line

You can also paste text in the files. To paste, the command is p and P. usually the paste command is different. The two commands indicate different types of paste. P command indicates pasting before the cursor position of general or specified buffer while p indicates pasting after the cursor position.

It may happen that your computer causes some problems when you edit in vi editor. At this point, the computer may hang and you will have to switch it off. Whatever you have edited will be saved in the recovery. So you can recover all the edited files later on easily. When you edit in VI editor, the editing is done on a temporary file. When the editing is over, and when the data is saved, the changes are transferred to the original copy.

Related Tags: vi editor ppt, how to edit invi, hpux vi command, two different types of commands vi has, vi text editor ppt

Related Content:

  1. How to Edit FLV
  2. How to Edit MIDI Files
  3. How to Edit DLL
  4. How to Edit Registry in Recovery Console
  5. How to Edit Music Files

Leave a Reply