Using Vi Editor

The vi editor is certainly not the easiest and most user-friendly text editor, but because of its wide availability and existence on most linux systems

The vi editor operates in two basic modes:

  1. Command mode
  2. Insert mode

when vi is started, it is in command mode. This mode allows you to enter commands to edit files or navigate your text file. However, you can only add or insert text by using the insert mode. from command mode, you can enter insert mode by typing the letter i. To return to command mode, use the Escape key

Editing text files:

The filename can be a new or existing file. Remember that when you first start vi, you are initially in command mode. if you are working on a new file, you can immediately type the letter i to enter into insert mode and start adding text

If you are working on an existing file, you can use the cursor keys, or the h,j,k,l keys to navigate to where you want to begin.

You can use the CTRL-f or CTRL-b to move ahead or back a page

To insert text at an exact point, you can type the letter i for insert and start adding your text, Other options include the letter a, Which adds text next to the cursor location, and the letter o, which starts your text on the next line below the current one.

if you make a mistake while typing, you can use the backspace key to delete characters. if you want to delete characters in command mode, hit the Escape key, and then use the letter x to delete characters one at a time. If you want to delete an entire line, use the dd command. The command dw deletes only the entire word that your cursor is currently on

To save your file, hit the Escape key to enter command mode, and then type :w . To save and exit out the vi editor, use the :wq command. Or you can use an equivalent to the :wq command and type the letters ZZ in command mode to save and exit the file

If you want to exit without saving your file, use the :q command. This command asks you if you want to save the file before quitting. If you want to bypass the prompt, use the :q! command

Advantages of using vi Editor:

You can ask your self why i will use an editor, there are many easy to use editors like gedit or any other editor?

vi editor is a MUST.