How to fix "bash: vim: command not found" error

Endrit Qerreti

Endrit Qerreti

Vim is one of the most popular open source text editors that you can use on Linux.

If you were trying to use vim on your terminal, and got the error " bash: vim: command not found" it means that the command that you were trying to run was not understood by your system.

In this tutorial, you will learn what causes the error " bash: vim: command not found" , and how to fix it.

Why does this error happen?

There are various reason why this error happens. It could happen for example when:

1) Vim installation is broken

2) Vim is installed but it's not added on your PATH variable, which means your system doesn't know where Vim working path is, so when you run vim you get an error like above.

3) Vim is not installed

Fix the error "bash: vim: command not found"

Step 1 - Update your system

Before installing Vim on your machine, update your system packages if you haven't updated them recently.

sudo apt update

Step 2 - Install Vim

To install Vim on your machine, you can easily do so by downloading and installing the official package of vim. Vim is available on main Debian repositories, so you don't need to add an external repository in order to install Vim.

To install Vim, simply run the command below.

sudo apt install vim

Step 3 - Verify Vim Installation

Now Vim is installed on your system. However, before launching vim, make sure that your vim installation is not broken.

You can check vim version and see if vim is able to run.

vim -v

Note: If the command above doesn't work even after installing vim, then you need to add Vim to your PATH.

Step 4 - Add Vim to PATH

Vim's binary is located at /usr/bin/vim , to add Vim PATH to your ~/.bashrc file, run the command below.

export PATH=$PATH:/usr/bin

Next, to make those changes permanent, source your ~/.bashrc

source .bashrc

And now you should be able to use vim on your terminal



In this tutorial, you learned how to fix the error "bash: vim: command not found" on Linux.

By now this error should be fixed, and you should be able to use vim.