How to Enable Syntax Highlighting in "vi" in "Ubuntu/Kubuntu"

Asked by burrashiva


Why is that syntax highlighting NOT shown in Ubuntu/Kubuntu vi command?
I tried installing all vi/vim common and other available packages depending on vi to get this ...but could not succeed.

If I want syntax highlighting in vi in Ubuntu/Kubuntu, what do i do?
Could some help me ?

I see that in Mandrake/Redhat, the Syntax highlighting is by default active.
So, once we open a .f (fortran), or .C(C++) or .java, automa[tg]ically the highlighting is seen.

why not in Kubuntu? Definitely some package I have not installed.
I love Kubuntu though I was using others for past few years. Now I shifted to Kubuntu and I think it is for Good.
thanks alot.

Question information

English Edit question
Ubuntu vim Edit question
No assignee Edit question
Solved by:
Chris O'Halloran
Last query:
Last reply:
Revision history for this message
Cesare Tirabassi (norsetto) said :

Thank you Prasad.

You mention you tried to install available packages depending on vi, but, have you installed vim-runtime?

The standard vim package installed on Debian systems is vim-tiny.
This package contains a minimal version of vim compiled with no
GUI and a small subset of features in order to keep the package
size small.
If you want additional features (for instance syntax highlighting),
you should download the vim-runtime package.
You can donwload this with the following command:

sudo apt-get install vim-runtime

I hope this helps.

Revision history for this message
Mariano Mara (marplatense) said :

Additionally, in case you miss a syntax file, to troubleshoot or perform manually the syntax update process:
1- Create (if it does not exist) or edit the file: .vimrc located in your /home.
2- Add:
     syntax on
3- Save the file.
4- cd into the .vim folder in your /home/youruser.
5- cd into the "syntax" folder in /home/youruser/.vim (create the folder if it does not exist)
6- download your favorite syntax files (e.g.: ) and paste them in /home/youruser/.vim/syntax/
7- restart vim with the file you want to see highlighted (obviously, you downloaded the syntax file in the previous step).

Revision history for this message
propagandist (propagandist) said :

If this is your own box then you will probably want to modify /etc/vim/vimrc and uncomment the things you would like on by default as well.

Revision history for this message
Best Chris O'Halloran (fattybones) said :

Install package vim-full. No need to download custom syntax files or anything.

Revision history for this message
burrashiva (burrashiva) said :

your suggestion doesnt seem to work. Just now Installed vim-full.

Mandriva was automatically showing the syntax highlighting for my php, fortran and C++ programs,
which I mentioned earlier.

any suggestions.
thank you,.

Revision history for this message
bhargi (bhargava) said :

Hello thanks my syntax highlighting works just did edited

Ubuntu 7.10


syntax on

Revision history for this message
Rangana Withanage (rswithanage) said :

I am using Ubuntu 8.04 Hardy Heron release.

apt-get install vim-runtime


syntax on

didnt work for me.
Also vim-runtime package took a whopping 24MB disk space when installed.

apt-get install vim-full

worked fine.

Revision history for this message
Tim Abell (tim-abell) said :

It would seem that vim-full is a transition package to vim-gnome (according to aptitude).
On a server this means that installing vim-full pulls in half of gnome, which is not desirable.

The following was enough to enable syntax highlighting, and only had one missing dependency for me:
sudo apt-get install vim
(along with editing ~/.vimrc as above)

Revision history for this message
Tathagata (tathagatadg) said :

Thanks for the help people. To summarize

1. sudo apt-get install vim-runtime vim-full
2. sudo vi /etc/vim/vimrc -> search for syntax, remove ", save.

Be prepared for a LOT of download.

Revision history for this message
John O. (jorleans-atgfreight) said :

sudo apt-get install vim-full will install vim-runtime. The whole thing is about 36MB.

Revision history for this message
catchjohn (john-catchjohn) said :

After many tries with no success, i have been able to successfully get vim full installed with apt-get.

What you need to do is do an apt-get remove on all vim related packages.

something to the effect of
apt-get remove vim vim-common vim-runtime vim-full

then updatedb and locate vim

remove anything else that might be left behind. This was my problem. Some how there were additional files on my machine that caused a vim install to not get all the files needed.

then just simply do this:
apt-get install vim

if you dont have a ../vim/vim*/syntax folder then it was not installed right. Keep trying by removing all files and makeing sure everything is off the system before installing vim again.

Revision history for this message
nanda (nanda-it2004) said :

hi guys ... i tried the same ...uncommented /etc/vim/vimrc ... it worked..thanks for the posting mates.......

Revision history for this message
Luis González (locoluis) said :

If you created a ~/.vimrc before upgrading, ensure that the runtimepath is still correct.

For example, you might have upgraded from VIM 7.2 to VIM 7.3, yet your runtimepath is still pointing to the vim72 folder instead of the vim73 folder.