Vim is a text editor that allows to create and modify text files via command line. Vim is an improved version of the old Unix Vi text editor, which provides syntax highlighting, unlimited undo, macros and other features.
This tutorial shows how to install Vim on Ubuntu 22.04.
Run the following command to update the package lists:
sudo apt update
sudo apt install -y vim
Once the installation is finished, check Vim version:
To create a new file or edit an existing file, type
vim command followed by filename:
If missing required permissions, then execute the command as superuser.
sudo vim /var/log/dpkg.log
The file is opened in read-only mode. To start editing the file, we need to switch to insertion mode by pressing the letter
i. When finished editing the file, exit the insertion mode by pressing the
ESC. To save the file and exit Vim, type
:wq command and press the
Enter key. To exit without saving, type
If you want to completely uninstall Vim and related dependencies, execute the following command:
sudo apt purge --autoremove -y vim