Installing VIM on Linux

by Nathan Wallace (Oct 28, 1999)


These instructions describe the installation of Vi IMproved on Linux. They were written specifically using VIM 5.5 on Red Hat 6.1.

Installing VIM is the first thing I do on any computer since it increases my productivity dramatically.

Getting VIM

  1. You need to perform this installation as root. You can install VIM locally for your own use, but I like to make it available to all users on the machine.
        su root

  2. I put all my downloads in /usr/local/download. You might need to create that directory now:
        mkdir /usr/local/download

  3. Now we can get VIM from your nearest mirror. You need to get 2 files, vim-5.5-rt.tar.gz and vim-5.5-src.tar.gz. Here are the ftp commands:
        cd /usr/local/download
        cd pub
        cd editors
        cd vim
        cd unix
        get vim-5.5-rt.tar.gz
        get vim-5.5-src.tar.gz

Installing VIM

  1. First we must unpack the distribution. Don't be scared by this fairly powerful tar command, it just unzips and extracts the tar into /usr/local (..).
        tar xzf vim-5.5-rt.tar.gz -C ..
        tar xzf vim-5.5-src.tar.gz -C ..

  2. Create a link to the vim version for convenience:
        cd ..
        ln -s vim5.5 vim

  3. Now we can compile VIM:
        cd vim
        cd src

  4. And install the VIM binaries in your path:
        make install

  5. You can check that the installation worked by typing:

  6. Remember that VIM can be used in the graphical mode like above or in a console using:
  7. If you are new to VI and VIM then you should probably work through the tutorial:

Running the New Version

  1. Just about every unix system has vi installed. On Red Hat, vi is just vim running in compatible mode (ie: lots of features turned off). Depending on how your original system was configured you may still be using an old version of vim, not the freshly installed one. My system has vi installed as:
    This is actually version 5.4 of vim (you can tell by executing :version or looking at the startup screen). I changed it to use the new version by doing this:
        cd /bin
        mv vi vi.old
        ln -s /usr/local/bin/vim vi

  2. You may also like to check that the newly installed programs are the ones being run. If there is an old version before the new one in the system path then it will be executed. You can see the location of an executable on the path with the which command:
        which vim
    On my system this returns the new version:

Setting Up Your VIM Environment

  1. You can configure your VIM options through an initialization file. For more information about this in VIM type:
        :help vimrc

  2. I like to use the following options:
        set nowrap
        set tabstop=4
        set shiftwidth=4
        set smartindent
        set expandtab
        map Y y$
        set bs=indent
        set ruler
        " Switch syntax highlighting on, when the terminal has colors
        " Also switch on highlighting the last used search pattern.
        if has("gui_running")
          syntax on
          set hlsearch
    These basically just set up tabs to work as 4 spaces, turns on autoindenting, changes Y to yank the rest of the current line and turns on syntax highlighting only when we are in gui mode.

  3. The options above need to be saved into a file. I want them available to all accounts (since only I use the machine) so I put them in the global location:

  4. If you want settings specific to a certain user then create a config file in their home directory. For example: