VI is a powerful console-based text editor. It is deservedly one of the most popular tools in Unix systems, thanks to its speed and extensive capabilities for working with text. However, it can be a bit challenging to master. That’s why we’ve compiled the essential commands for the Vi editor in this article.
Vim includes additional features such as syntax highlighting, mouse support, and much more. The basic commands and key combinations remain the same in both VI and Vim. Therefore, by learning Vi, you’ll automatically grasp the basics of Vim and its derivatives.
Here are five reasons why I recommend learning Vi and Vim:
Vi is always available as it is required by the POSIX standard.
Vi/Vim is well-documented. The editor has its own user manual—just enter the :h command in command mode.
Vi/Vim supports numerous plugins. Most of them can be found onvimawesome.com, one of the most popular places for plugin downloads.
To start the program, enter the command:
vi
You can also open a file by specifying its name. If the file exists, it will open for editing; if not, a new file will be created:
vi your_file.txt
Vi operates in two different modes:
Command mode: Used for navigation, copying, and pasting.
Insert mode: Used for direct text input.
💡 This mode is enabled by default when you open Vi/Vim.
It is used for actions like moving through text, copying, pasting, deleting, or replacing text (but not editing it). To return to this mode, press <Esc>.
h — move left.
j — move down.
k — move up.
l — move right.
x — delete the character under the cursor.
dd — delete the current line.
y — copy the selected text.
yy — copy the current line.
💡 This mode is activated in normal mode by pressing :.
Examples of commands:
:wq — save changes and exit.
:q! — exit without saving.
:h — display help.
:/string — search for a string.
💡 This mode is used for editing text.
Switch to it by pressing:
i — insert text before the cursor.
I — insert text at the beginning of the line.
a — append text after the cursor.
💡 This mode allows you to select text, which is particularly useful for working with large paragraphs.
v — select characters.
V — select lines.
Ctrl+V — block mode.
Vi/Vim is available on almost all Unix-like systems. By investing a little time to master it, you’ll gain access to one of the best text editors out there.