Install Vim on Ubuntu 22.04

Install Vim on Ubuntu 22.04

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.

Install Vim

Run the following command to update the package lists:

sudo apt update

Install Vim:

sudo apt install -y vim

Once the installation is finished, check Vim version:

vim --version

Testing Vim

To create a new file or edit an existing file, type vim command followed by filename:

vim test.txt

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 :q! command.

Editing File with Vim on Ubuntu

Uninstall Vim

If you want to completely uninstall Vim and related dependencies, execute the following command:

sudo apt purge --autoremove -y vim

Leave a Comment

Cancel reply

Your email address will not be published.