Linux Vi Editor
Linux Vi Editor
Vi Editor
The Linux VI Editor is a text based editor used Linux, useful for editing
configuration files or creating plain text documents. Vi is one of the most
popular text editors texte under Unix type systems (with Emacs and pico).
Under Linux, there is a free version of Vi called Vim (Vi Improved). Vi
(pronounced vee-eye) is an editor that is fully in text mode, which means
that all actions are carried out with the help of text commands. This editor,
although it may appear of little practical use at first, is very powerful and
can be very helpful in case the graphical interface malfunctions. Vi was
originally developed by William Joy at Berkeley University and first
officially included in AT&T System 5 Unix. It started out as a line-
oriented editor for dumb terminals. The Vi editor, or Vi improved (VIM)
is an enhancement by Bram Moolenaar it's the version that people use
today. The vi editor comes with every version of Linux or Unix. It's a
terribly unfriendly beast of an editor, but you should know about it
because someday you're likely to find yourself on a system where you
have no other choice but to use it
All Linux configuration files are written in plain English, easy to read and
to adapt. You use a text-editor to write or make changes to such files.
Using vi is similar to using other editors in that you can see your file on
the screen (this is not the case with a line editor, for example), move from
point to point in the file, and make changes. But that's where the
similarities end. Cryptic commands, a frustrating user interface, and the
absence of prompts can all drive you up a wall. The two most popular,
powerful, and unfortunately "difficult" text editors, both of which are
found in every Linux distro, are Vi and Emacs
To start Vi, open a terminal or console and simply type "vi" (without the
quotation marks) followed by the name of any existing file or a new file
you want to create. Vi works in two main modes, one for editing text and
the other for giving commands. To switch between the two modes you use
the I and Esc keys. The program opens in the Command mode, which is
used for cursor movements, delete, cut, copy, paste, and saving changes.
The hardest thing to understand about vi is the concept of modes. When
using vi, you're always in either Command or Input mode. The vi editor
has three modes, command mode, insert mode and command line mode.
Basic commands
Command Description
:q! - Forces the editor to quit without saving (even if changes were
made to the document)
Editing commands
Command Description
dxd - Deletes x lines starting with the one currently under the cursor
nx - Deletes n characters starting with the one currently under the
cursor
x>> - Indents x lines to the right starting with the one currently under
the cursor
x<< - Indents x lines to the left starting with the one currently under
the cursor
:s/chain_to_be_replaced/replacement_chain/
IThe replacement can be made throughout the entire document with the
following syntax:
:%s/chain_to_be_replaced/replacement_chain/