vim

Vim command not found after Linux install, how to resolve

As people migrate from completely GUI-based operating systems to Linux or Unix-like systems, they often have difficulty dealing with the command line. Using the Terminal is a foreign idea to them, and it’s very easy to run into common errors, much like the one that is our subject today. So, if you happen to be one of the people having trouble using Vim, this article is for you.

Getting started

Before we get into the technicalities of the matter, let’s chalk out some of the main points of discussion that we’ll go over.

What is Vim?

Vi Improved, shortly known as Vim, is a common text editor. Although it can be used to edit any kind of text for any purpose, most Linux users use it to edit computer programs. It’s all thanks to its highly configurable and efficient nature that it is known as the ‘programmer’s editor’. Many even consider it to be a full-fledged Integrated Development Environment (IDE).

The good news for beginners is that Vim features an intuitive interface and is very easy to use. It’s a lot like a Linux alternative for Notepad in Windows.

What causes the Vim command error?

You might have tried to perform some tasks using Vim by copying commands from a website. This is mostly why Linux beginners run into the very common error that says “command “vim” not found”.

Vim is not a default command of Ubuntu, and neither do you have the Vim utility preinstalled on your Linux system. This is why when you enter a Vim command in the Terminal, the system fails to recognize the keyword. The picture below shows what this error looks like.

As you can see, the command is not found because there is no such thing as Vim installed on your computer. So, the reason why this error occurs is that you have not installed Vim.

How to resolve this error?

We have seen in the previous section that the Terminal fails to recognize the Vim command because the utility hasn’t yet been installed on the system. So, we can resolve the error by simply installing the text editor.

The Terminal also points the user in the right direction by telling them what commands they need to run to install this utility. We will be using the first one. Open up a new Terminal session through the Activities menu or pressing Ctrl + Alt + T on your keyboard. The next step is to install Vim by running the command given below.

$ sudo apt install vim

The output for this command should look something like the image below.

It should take a few moments to install the text editor, and once it’s finished, you are good to go. Try running the Vim command now and see if the problem persists.

As you can see in the screenshot above, when you run the Vim command now, a new editor opens in the Terminal.

Therefore, we have successfully resolved the Vim command “not found” error. Now that we have looked at how you can get Vim to work, let’s discuss how you can use it as a beginner.

How to use Vim?

When starting off with Vim, it is important to note that Vim has three main modes of operation. There are others as well, but you probably would not need to use those as a beginner. And if you’re not a beginner, you wouldn’t be reading this in the first place.

  • Normal
  • Insert
  • Command Line

The normal (default) mode is used for simple editing and viewing text documents. Insert mode is used for modifying and inserting text in the files. Finally, the command line mode is meant to save your data and exit the application.

Once you start a new instance of Vim by running it through the Terminal, you are already in Normal mode. You can make sure that you are in Normal mode by pressing the Esc button.

Moreover, you can enter the command line mode by entering a colon (:) in Vim. Also, entering “:q!” without the commas exits out of Vim without saving any changes.

You can use Vim to edit code files; for example, you can open and edit .c or .java files through Vim.

Enter “:help” in the Normal mode to see some instructions regarding its usage.

That about concludes this short guide on getting started with Vim. There are many resources on the internet that go into great detail about Vim and how to use it. As this is not the subject of this particular article, we will stop here.

Additional information

  • Released by Bram Moolenar in 1991, Vim is one of the most popular text editors among Linux users.
  • Vim is mainly a command-line-oriented utility; however, people that favor GUI should give gVim a try – the GUI version of this editor.
  • Vim is extremely customizable and lets the users take matters into their own hands. This is an important contributing factor towards programmers’ liking towards this editor

Conclusion

In this article, we learned several things about Vim. We saw how one could install it, therefore fixing the “command not found” error that many users run into. Furthermore, we also briefly covered how a beginner can get started with using Vim. Finally, we learned some basic facts and additional information about this text editor. Hopefully, this has been an instructive and informative read for you.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer by degree, Blogger by skills who loves to write about tech, develop websites & do SEO. You can reach out to me on LinkedIn.