Ubuntu Linux: Install vim Text Editor

by on May 19, 2013 · 10 comments· LAST UPDATED June 4, 2013

in , ,

I recently switched from OS X to Ubuntu. When I run the 'vim file.c' command at terminal, I see an error message that read as follows:

The program 'vim' can be found in the following packages:
* vim
* vim-gnome

* vim-tiny
* vim-athena
* vim-gtk
* vim-nox
Try: apt-get install <selected package>

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
Estimated completion timeN/A
How do I fix this problem and why vim is not a default text editor on Ubuntu Linux? How can I install full-fledged vim text editor in Ubuntu Linux?

Vim (Vi IMproved) is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing config files and programs written in shell, python, perl, c/c++ and more.

Installing Vi IMproved [VIM] text editor on Ubuntu

Open a terminal and/or login to the remote Ubuntu server using the ssh client. Type the following apt-get command to install vim text editor:
sudo apt-get install vim
sudo -s
apt-get install vim

Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libgpm2 libpython2.7 vim-runtime
Suggested packages:
  gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
  libgpm2 libpython2.7 vim vim-runtime
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,530 kB of archives.
After this operation, 28.1 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.service.networklayer.com/ubuntu/ precise/main libgpm2 amd64 1.20.4-4 [17.2 kB]
Get:2 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main libpython2.7 amd64 2.7.3-0ubuntu3.1 [1,188 kB]
Get:3 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main vim-runtime all 2:7.3.429-2ubuntu2.1 [6,277 kB]
Get:4 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main vim amd64 2:7.3.429-2ubuntu2.1 [1,048 kB]
Fetched 8,530 kB in 1s (8,515 kB/s)
Selecting previously unselected package libgpm2.
(Reading database ... 57205 files and directories currently installed.)
Unpacking libgpm2 (from .../libgpm2_1.20.4-4_amd64.deb) ...
Selecting previously unselected package libpython2.7.
Unpacking libpython2.7 (from .../libpython2.7_2.7.3-0ubuntu3.1_amd64.deb) ...
Selecting previously unselected package vim-runtime.
Unpacking vim-runtime (from .../vim-runtime_2%3a7.3.429-2ubuntu2.1_all.deb) ...
Adding 'diversion of /usr/share/vim/vim73/doc/help.txt to /usr/share/vim/vim73/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim73/doc/tags to /usr/share/vim/vim73/doc/tags.vim-tiny by vim-runtime'
Selecting previously unselected package vim.
Unpacking vim (from .../vim_2%3a7.3.429-2ubuntu2.1_amd64.deb) ...
Processing triggers for man-db ...
Setting up libgpm2 (1.20.4-4) ...
Setting up libpython2.7 (2.7.3-0ubuntu3.1) ...
Setting up vim-runtime (2:7.3.429-2ubuntu2.1) ...
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.3.429-2ubuntu2.1) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode.
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode.
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

You can now use vim text editor:
$ vi file.c
$ vim file.c
$ sudo vim /etc/sysctl.conf

Sample outputs:

Fig.01: Vim in action on Ubuntu

Fig.01: Vim in action on Ubuntu

For more information read the apt-get(8) man page.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 10 comments… read them below or add one }

1 Krisztian May 19, 2013 at 8:03 pm


I also use this ultimate vimrc for vim (with many plugins, color schemes, etc.): https://github.com/amix/vimrc



2 Leaman Crews May 20, 2013 at 1:18 am

As far as why vim is not installed by default in Ubuntu, I’d say it’s because Ubuntu is geared towards a non-technical crowd that: a) will not ever use a command-line text editor; and b:) will figure out how to get it installed easily enough if they want it.

Some other things that don’t ship with Ubuntu by default are dev tools (gcc, make, etc.) or ssh server. Most Linux distros ship with these pre-installed, but I assume these are also absent because of what Canonical perceives as Ubuntu’s target audience.


3 meow June 10, 2013 at 2:54 pm



4 karthik July 22, 2013 at 6:24 am

hey i’ve tried the first two commands but i still have problem it gives the following output:
root@cbitlab1:/home/cbitlib1# sudo -s
root@cbitlab1:/home/cbitlib1# apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package vim is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘vim’ has no installation candidate


5 Heisenberg January 24, 2014 at 5:10 pm

Hi Karthik, I’ve the same problem, do you solve this?


6 Nix Craft January 24, 2014 at 7:49 pm

Run the following command and past its output:

lsb_release -a


7 Leaman Crews January 24, 2014 at 6:05 pm

Karthik & Heisenberg,

Try to install vim-nox instead and see what happens:

apt-get install vim-nox

If that still doesn’t work, search for vim in your repositories like so:

apt-cache search vim

And see what “vim” packages you have available to install.


8 Nix Craft January 24, 2014 at 7:48 pm

Run the following command and past its output:
lsb_release -a


9 mir islam July 23, 2014 at 8:01 am

when i install vim or vim-nox, system showed the following output? What I do now?
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?


10 Leaman Crews July 23, 2014 at 10:41 pm

@mir islam, that means you have another application open that can install or update applications.

Check to see if you have Software Update, Ubuntu Software Center, Synaptic Package Manager, or another Terminal tab open that is installing or updating. Close any and all of these that you may have open, and then run the commands again. It should work this time.


Leave a Comment

Tagged as: ,

Previous Faq:

Next Faq: