VI Editor
VI Editor
2
VI editor
The VI editor is the most popular and classic text editor in the Linux
family. Below, are some reasons which make it a widely used editor –
• It is available in almost all Linux Distributions
• It works the same across different platforms and Distributions
• It is user-friendly. Hence, millions of Linux users love it and use it for their
editing needs
• An improved version of the vi editor which is called the VIM has also
been made available now. Here, VIM stands for Vi IMproved.
vi is generally considered the de facto standard in Unix editors because
• It's usually available on all the flavors of Unix system.
• Its implementations are very similar across the board.
• It requires very few resources.
• It is more user-friendly than other editors such as the ed or the ex.
• It is available on almost all operating systems.
• A smart range of shortcuts that comprise of short keystrokes.
• You can use vi as an excellent html editor.
• The vi commands are so rich that you hardly need to take your hands off
the keyboard.
• vi editor creates small size files making it light on your storage.
• Its free.
Starting the vi Editor
vi filename
• Creates a new file if it already does not exist, otherwise opens an existing file.
vi -R filename
• Opens an existing file in the read-only mode.
view filename
• Opens an existing file in the read-only mode.
Operation Modes
• Command mode
• Insert mode
• Command mode also enables you to find and replace text in a file.
Moving cursor across a file:
• You can usually move the cursor across text in your files with the up,
down, left and right arrow keys of your keyboard.
• In case you are using a remote terminal and the arrow keys fail to
behave in the desired manner, you can use the following keys as
substitutes:
• Move left: h
• Move right: l
• Move up: k
• Move down: j
8
Insert Mode
• To enter text in your file, you need to be in the insert mode.
Everything that you type in this mode will be considered text and
added to your file.
• The Esc key will take you to the command mode from insert mode.
To save and quit
• You can save and quit vi editor from command mode. Before writing
save or quit command you have to press colon (:).
13
To switch from command to
insert mode:
Command Action
i Start typing before the current character
Commands Action
j To move down
k To move up
h To move left
l To move right
To delete
In order to delete a character from your file, move the cursor until it is on the
incorrect letter and then type x key. To remove more characters, say three,
type 3x.
Commands Action
https://www.javatpoint.com/vi-editor
Copying text