Ubuntu Linux: Install vim Text Editor

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>

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 (when promoted type your own password):
sudo apt-get update
sudo apt-get install vim

OR
sudo -s
sudo apt-get update
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:
  bind9utils
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

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

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.