Posts Tagged ‘vi’

How To: Get Syntax Highlighting Working for Vi in Ubuntu

Wednesday, January 2nd, 2008

If you can’t get syntax highlighting to work in a new Ubuntu install, it’s probably because the standard Vim install in Ubuntu is from the vim-tiny package. This is a cut-down version of Vi that does very little but edit files. If you want full Vi (with syntax highlighting), you need to uninstall the vim-tiny package and install vim-runtime:

  1. sudo apt-get update - may as well make sure we’re aware of the latest package updates
  2. sudo apt-get remove vim-tiny - we’re going to replace this package. You’ll be asked if you want to uninstall ubuntu-minimal. It’s safe to do this (explanation below).
  3. sudo apt-get install vim-runtime - this is quite a big package (20 meg or so).

Now we have the latest version of Vim. The command :syntax on will turn on syntax highlighting. To have it on automatically for yourself, create the file ~/.vimrc and enter the text syntax on. You can also edit /etc/vim/vimrc (as root) and change the appropriate lines to make the settings global instead. You can also set whether the background is dark or light (which affects the colour scheme).

When uninstalling vim-tiny, you’re prompted about the removal of ubuntu-minimal. This is an umbrella package that has lots of dependencies to packages needed for a basic workable Ubuntu install. If you uninstall one of the packages, you’ll need to uninstall the umbrella package too. This doesn’t affect the other dependencies so it should be safe.

As an aside, it seems to work better over Putty too. Happy days!