VI Editor

Starting the vi Editor

The following table lists out the basic commands to use the vi editor −

poi

=> Following is an example to create a new file testfile if it already does not exist in the current working directory −

poi.png

Moving within a File

To move around within a file without affecting your text, you must be in the command mode (press Esc twice). The following table lists out a few commands you can use to move around one character at a time

poi

Editing Files

To edit the file, you need to be in the insert mode. There are many ways to enter the insert mode from the command mode −

poi.png

 

Deleting Characters

Here is a list of important commands, which can be used to delete characters and lines in an open file

poi.png

 

Change Commands

You also have the capability to change characters, words, or lines in vi without deleting them. Here are the relevant commands −

poi.png

 

Copy and Paste Commands

You can copy lines or words from one place and then you can paste them at another place using the following commands

poi