Cannot install vim

You have an outdated package list.

Run this command:

sudo apt-get update && sudo apt-get install vim

What that will do is update your package list, and then try to install vim.


When doing

$ sudo apt-get install vim

I got :

Reading package lists... Done  
Building dependency tree  
Reading state information... Done

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 vim : Depends: vim-common (= 2:7.3.154+hg~74503f6ee649-2ubuntu2) but 2:7.3.154+hg~74503f6ee649-2ubuntu3 is to be installed
E: Unable to correct problems, you have held broken packages.

To solve this problem, I did:

sudo apt-get remove vim-common 
sudo apt-get clean && sudo apt-get purge 
sudo apt-get update && sudo apt-get install vim

I must say that the previous fix did the trick for vim installation but not for others packages which still gave me the same kind of issue(E: Unable to correct problems, you have held broken packages)

After searching a little more, I found on another forum a better fix. The fix has been given by Liam Proven(http://ubuntu.5.n6.nabble.com/E-Unable-to-correct-problems-you-have-held-broken-packages-td4355181.html).

In Synaptic (if you have it installed) or System Settings | Software Sources. Look for the option to find the fastest server. It usually picks a lightly-loaded mirror near you.

After setting the fastest server, I do not have any problem. Hope that is useful.


I also had broken packages in Synaptic and nothing was able to be installed. For me this solved the issue:

sudo apt-get clean && sudo apt-get purge

And then try to reinstall


The clue to the answer is in the "Unable to correct problems, you have held broken packages."

For broken package state issues I turn to aptitude (sudo apt-get install aptitude) because it has handy shortcuts for queing arbitrary changes to package states: for instance "+" to unhold, "=" to hold, "-" to remove, "_" to purge, and "g" to apply queued changes. "/" to search for packages.

But these commands may work. Un-holding vim-common is the important bit:

sudo apt-get update
echo vim-common install | sudo dpkg --set-selections
sudo apt-get install vim