Ubuntu Linux Install vim Text Editor using apt-get

I recently switched from macOS/OS X to Ubuntu. When I run the ‘vim file.c’ command at terminal, I see an error message indicating that vim is not installed. How do I fix vim not found error 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. In this tutorial, we will show you install install vim text editor on Ubuntu Linux.

ADVERTISEMENTS

Ubuntu Linux install vim using apt

The procedure is as follows:

  1. Open terminal application. You can also press CTRL+ALT+T keyboard shortcut
  2. Update package database by typing the sudo apt update command
  3. Search for vim packages run: sudo apt search vim
  4. Install vim on Ubuntu Linux, type: sudo apt install vim
  5. Verify vim installation by typing the vim --version command

Let us see all steps in details to install vim on Ubuntu system.

How to install full version of Vim on Ubuntu

First open the terminal application and then update package database using the apt command or apt-get command:
sudo apt update

Hit:1 http://us-central1.gce.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://us-central1.gce.archive.ubuntu.com/ubuntu focal-updates InRelease             
Hit:3 http://us-central1.gce.archive.ubuntu.com/ubuntu focal-backports InRelease           
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease                           
Hit:5 http://archive.canonical.com/ubuntu focal InRelease                                  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

Apply all patches on Ubuntu Linux:
sudo apt upgrade

Search for vim package

Run any one of the following command:
sudo apt search vim
sudo apt-cache search vim
sudo apt-cache search vim | grep editor

vim - Vi IMproved - enhanced vi editor
vim-tiny - Vi IMproved - enhanced vi editor - compact version
elvis-tiny - Tiny vi compatible editor for the base system
formiko - reStructuredText and MarkDown editor and live previewer
kakoune - Vim-inspired, selection-oriented code editor
libghc-yi-keymap-vim-dev - Vim keymap for Yi editor
libghc-yi-keymap-vim-doc - Vim keymap for Yi editor; documentation
libghc-yi-keymap-vim-prof - Vim keymap for Yi editor; profiling libraries
python3-editor - programmatically open an editor, capture the result - Python 3.x
vim-addon-manager - manager of addons for the Vim editor
vim-athena - Vi IMproved - enhanced vi editor - with Athena GUI
vim-editorconfig - EditorConfig Plugin for Vim
vim-gtk - Vi IMproved - enhanced vi editor (dummy package)
vim-gtk3 - Vi IMproved - enhanced vi editor - with GTK3 GUI
vim-nox - Vi IMproved - enhanced vi editor - with scripting languages support
vis - Modern, legacy free, simple yet efficient vim-like editor

You don’t have to install above vim packages. Typically we eiter install vim or vim-tiny on Ubuntu Linux.

Get info about vim package of your choice

Use the apt as follows:
apt show vim-tiny
apt show vim

Package: vim
Version: 2:8.1.2269-1ubuntu5
Priority: optional
Section: editors
Origin: Ubuntu
Maintainer: Ubuntu Developers 
Original-Maintainer: Debian Vim Maintainers 
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3111 kB
Provides: editor
Depends: vim-common (= 2:8.1.2269-1ubuntu5), vim-runtime (= 2:8.1.2269-1ubuntu5), libacl1 (>= 2.2.23), libc6 (>= 2.29), libcanberra0 (>= 0.2), libgpm2 (>= 1.20.7), libpython3.8 (>= 3.8.2), libselinux1 (>= 1.32), libtinfo6 (>= 6)
Suggests: ctags, vim-doc, vim-scripts
Homepage: https://www.vim.org/
Task: server, cloud-image, lubuntu-desktop
Download-Size: 1238 kB
APT-Sources: http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 Packages
Description: Vi IMproved - enhanced vi editor
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 Many new features have been added: multi level undo, syntax
 highlighting, command line history, on-line help, filename
 completion, block operations, folding, Unicode support, etc.
 .
 This package contains a version of vim compiled with a rather
 standard set of features.  This package does not provide a GUI
 version of Vim.  See the other vim-* packages if you need more
 (or less).

Installing 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 additional packages will be installed:
  libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libtdb1 libvorbis0a libvorbisfile3 vim-common vim-runtime
Suggested packages:
  libasound2-plugins alsa-utils libcanberra-gtk0 libcanberra-pulse ctags vim-doc vim-scripts
The following NEW packages will be installed:
  libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libtdb1 libvorbis0a libvorbisfile3 vim vim-common vim-runtime
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 9412 kB of archives.
After this operation, 42.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 vim-common all 2:8.1.2269-1ubuntu5 [85.1 kB]
Get:2 http://us-central1.gce.archive.ubuntu.com/ubuntu focal/main amd64 libasound2-data all 1.2.2-2.1 [19.0 kB]
....
..
...
Unpacking libpython3.8:amd64 (3.8.2-1ubuntu1.1) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../10-vim-runtime_2%3a8.1.2269-1ubuntu5_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.2269-1ubuntu5) ...
Selecting previously unselected package vim.
Preparing to unpack .../11-vim_2%3a8.1.2269-1ubuntu5_amd64.deb ...
Unpacking vim (2:8.1.2269-1ubuntu5) ...
Setting up libogg0:amd64 (1.3.4-0ubuntu1) ...
Setting up libtdb1:amd64 (1.4.2-3build1) ...
Setting up libasound2-data (1.2.2-2.1) ...
Setting up vim-common (2:8.1.2269-1ubuntu5) ...
Setting up libpython3.8:amd64 (3.8.2-1ubuntu1.1) ...
Setting up libvorbis0a:amd64 (1.3.6-2ubuntu1) ...
Setting up libltdl7:amd64 (2.4.6-14) ...
Setting up libasound2:amd64 (1.2.2-2.1) ...
Setting up vim-runtime (2:8.1.2269-1ubuntu5) ...
Setting up libvorbisfile3:amd64 (1.3.6-2ubuntu1) ...
Setting up libcanberra0:amd64 (0.30-7ubuntu1)

Verify vim installation

Run the following command:
vim --version
Ubuntu Linux Install vim Text Editor and Verify It

How do I edit file with vim

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

Conclusion

In this tutorial, you learned how to install vim text editor on Ubuntu Linux using the apt-get command or apt command. For more information read the apt-get(8) man page and see vim page here.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
24 comments… add one
  • Krisztian May 19, 2013 @ 20:03

    Hi.

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

    regards

  • Leaman Crews May 20, 2013 @ 1:18

    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.

  • meow Jun 10, 2013 @ 14:54

    I LOVE VIM

  • karthik Jul 22, 2013 @ 6:24

    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
    HELP ME!

  • Heisenberg Jan 24, 2014 @ 17:10

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

    • 🐧 Nix Craft Jan 24, 2014 @ 19:49

      Run the following command and past its output:

      lsb_release -a
  • Leaman Crews Jan 24, 2014 @ 18:05

    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.

  • 🐧 Nix Craft Jan 24, 2014 @ 19:48

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

  • mir islam Jul 23, 2014 @ 8:01

    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?
    user@user-HP-2000-Notebook-PC:~

    • Leaman Crews Jul 23, 2014 @ 22:41

      @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.

      • Phantom Apr 8, 2016 @ 7:38

        how to check what programs are running in background? I don’t have any other application running

  • Rupesh Sep 9, 2014 @ 5:05

    Hey,
    i tried your given command but i got the output as below

    rupesh123@ubuntu:~$ sudo apt-get install vim
    [sudo] password for rupesh123:
    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

    i don’t know what to do here….. and for your kind information i’m using ubuntu with VMWARE in my windows 8 PC

    plz must do reply

    • bikash Oct 28, 2015 @ 2:08

      i too have the same problem as Rupesh .
      Plz reply me the solution soon

      • nemo Mar 21, 2016 @ 6:07

        I met the problem too , please kindly reply me if you have resolved it.

        • 🐧 Vivek Gite Mar 21, 2016 @ 6:22

          Can you state the version of your Ubuntu software? Try:

          sudo apt-get update
          sudo apt-get install vim

          • nemo Mar 21, 2016 @ 8:41

            I was operated Ubuntu 14.10 with VMware Workstation
            after use your command ,it just show that some index files failed to download. They have been ignored ,or older ones used instead.

            • 🐧 Vivek Gite Mar 21, 2016 @ 12:19

              No. You can’t ignore those. You need correct entries in /etc/apt/sources.list. Here is my working file (backup your existing file before modification):

              ###### Ubuntu Main Repos
              deb http://us.archive.ubuntu.com/ubuntu/ trusty main universe multiverse 
              
              ###### Ubuntu Update Repos
              deb http://us.archive.ubuntu.com/ubuntu/ trusty-security main universe multiverse 
              deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main universe multiverse 
              
              • Nemo Mar 22, 2016 @ 13:17

                HI,Vivek Gite
                before got your reply, someone told me use command :
                apt-get remove vim-common
                apt-get install vim
                But it still can’t work out and I cannot use vi either
                Could you tell me how to modify the sources.list without vi ,thanks a lot.

              • Nemo Mar 23, 2016 @ 13:25

                oh,I find a solution to resolve it .I am a newbie of Linux and there are too much things to learn for me ,thanks anyway. If you don’t mind ,I want got your WeChat number and talk to you.

  • nitin Apr 7, 2015 @ 9:24

    firstly install all the required updates
    than try the command
    sudo apt-get install vim

  • Deepak kumar Jun 28, 2015 @ 14:01

    i don’t know what to do here….. and for your kind information i’m using ubuntu with VMWARE in my windows 8 PC

    plz must do reply as soon as posible.

  • praveen kumar Nov 21, 2015 @ 8:24

    Thanks leaman crews…

  • Avezou Jul 2, 2016 @ 13:11

    VIM is not installed in Ubuntu by default, but VI is.

  • steve Feb 5, 2017 @ 9:19

    Hello, what’s the official/trusted ppa repository to get vim updates?
    I have vim 7.3, I’d like to update to 7.4 so I can use blowfish2 encryption.
    Thanks for any help.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.