Monday, March 16, 2009

How to make vi colorful on xubuntu

Hi...
We started to study shell programming in school and we use VI to code some scripts. I noticed that all my colleagues using vi on ubuntu are very irritated and seem to envy their friends who use VI on Fedora 10 because it's very easy to use and colorful, it helps to detect syntax errors. Some of my friends started to regret installing Ubuntu instead of Fedora and even blamed me for recommending it. As an Ubuntu fan I looked for a solution for this tiny problem. I won't accept any lame remark about Ubuntu !! you need a colorful VI ? Here you are !


1- You have to install VIM which is "vi Improved" just tape this code in your console:

sudo apt-get install vim

2- After installing it you have to edit a file () and uncomment a parameter. To do so first you have to turn into root so type su and enter your root password:

su
then change this file mode for writing (so you can change its content)

chmod +w /etc/vim/vimrc

no open this file using vi if you want and uncomment syntax on. i.e erase the (") before syntax on in line 20.
vi /etc/vim/vimrc
After doing that save changes and exit using :wq
try writing something, save it and re-open it and you will find your beautiful colorful script. ENJOY !!

14 comments:

Anonymous said...

Nice tip.

Just mentioning that the root account is disabled by default on Ubuntu, so the easiest way to do it is to prefix commands from 2 onwards with "sudo".

Though if you're dealing with something like vi and vim, you're probably already know that...

Walid Debbech said...

Well, thanks for the tip.. It's a bad habit ... I always use "su" instead of "sudo" ...well it's easier to use sudo ! specially for beginners who haven't configured their root account yet .

Anonymous said...

why not just change the users .vimrc ?

Walid Debbech said...

how so?? Are u sure it works ??

Simon Piette said...

Baaah! Such an insecure tip.

Just create a ~/.vimrc with "syntax on" in it.

Tsvi said...

Just create a file called .vimrc in your home directory. Write the following line into it:

syntax on

This has multiple advantages:
a. No need for root access
b. Configuration is on a per user basis
c. If you accidentally tell Ubuntu to overwrite your vimrc configuration (when doing apt-get update) your configuration stays intact.
Using the /etc/vimrc configuration file is only interesting if all users will be using this config.

(By the way this method (of editing configuration files in $home) works with most apps)

Walid Debbech said...

I will try that.thanks folks !

Anonymous said...

Even though you recommend changing /etc/vim/vimrc, this can be somewhat dangerous. It is better to copy /etc/vim/vimrc to ~/.vimrc. The reason is that some updates can replace your "master" file in /etc and leave you without any customizations you've done.

Tim
kb0odu

Unknown said...

simple but great!!

Anonymous said...

Not sure if you're aware, but vim is available for every distribution of Linux, and many non-Linux systems, not just xubuntu.

and as has been pointed out you can edit the user's .vimrc, and put the line "syntax on" in that.

Had you written that, you could have aimed your article at *all* linux users.

Walid Debbech said...

@tekhammer:
the vim ( I mean VI improved) wasn't available in xubuntu.
ubuntu distribution has the basic vi version not the improved one.
Of course this technique of making vim colorful could works with all linux distributions. but the context of writing this article is making it work on xubuntu. I don't have a closer look to many linux distros but I know that Fedora10 users for example don't need to configure their vim because it's already configured to be colorful.
thank you for your remark. I should have put "making vim colorful" without the distro name. I will make more attention with the coming articles.
thanks

Nerdote said...

hey i wanted to drop a line but didn't find an email. Just wanted to get the scoop on your template. I'm digging that you have a margin on both sides of the main content. Anyways yo can respond right here or whatever (if you could/want to help) as i'll receive an email on follow-up comments.

Thanks & peace.

graphic design company said...

xubuntu is a very useful network..when i was doing some projects freelancing this media was very helpful..Your posts are great and simply mind blowing!
Thanks for sharing your knowledge!

- J.
Web Designing

Aansy Stone said...

using Ubuntu is quite new experience for me, i had never encourted with Ubuntu before.....now i hav start understanding it and got the new technique from you ....thanx for that sharing