Syntax color highlighting enables parts of text (tags, functions, etc) to be shown in a different color to ease the visualization of the text file, this is done based on the file extension (.php,.sql,.html,etc).
To enable this function in Ubuntu or other distros edit or create the file .vimrc which must be located in the user home directory:
vi /root/.vimrc
add this line:
:syntax enable
That's it.
20 comments:
you said:
vi /root/.vimrc
add this line:
:syntax enable
My comment is that /root is not your home directory.
Anyhow, when I tried this with my recently installed "ubuntu fiesty fawn" did:
sudo vi .vimrc
and added the line, :syntax enable
The root's home directory is "/root", if you use another user you just use that particular user's home directory like "/home/user/". I use to work as root normally.
When I follow these instructions, I get:
Error detected while processing /home/xxx/.vimrc:
line 1:
E319: Sorry, the command is not available in this version: :syntax enable
(running 7.04). Any help?
Try installing the vim-common package , that may solve the problem
Also, you do not need the ':' before syntax enable in the vimrc file. You can just place settings there. The colon is used when you are already editing a file and you must type ':' to enter the command mode.
apt-get install vim-full worked for me. Thanks for the post!
thanks that worksssss
ubuntu 7.10 comes with a small version of vim. The package is called "vim-tiny". If you want syntax highlighting just uninstall this package and install "vim" package instead which has been compiled with a standard set of features. Be aware that "vim" package does not provide a GUI version of vim. If you want that, install "vim-full" package.
Anyway, thanks to all of you guys, this post solved my syntax problem :)
You do _not_ need vim-full.
in your ~/.vimrc file enable syntax highlighting by adding 'syntax on'
Make sure you have vim-nox installed. It takes a lot less disk space than vim-full (if space is an issue). For servers, I use vim-nox.
thank you guys, this post really solved a long time headache of mine :):)
I cannot find a .vimrc file in root/ or usr/xx/ directory. There is one located under etc/vim ... But its not a hidden file.
drwxrwxrwx 2 root root 4096 2008-04-22 10:49 .
drwxrwxrwx 131 root root 12288 2008-07-13 21:27 ..
-rwxrwxrwx 1 root root 2317 2008-07-13 21:17 vimrc
-rw-r--r-- 1 root root 665 2008-01-31 04:52 vimrc.tiny
Btw, I am using ubuntu
I cannot find a .vimrc file in root/ or usr/xx/ directory. There is one located under etc/vim ... But its not a hidden file.
drwxrwxrwx 2 root root 4096 2008-04-22 10:49 .
drwxrwxrwx 131 root root 12288 2008-07-13 21:27 ..
-rwxrwxrwx 1 root root 2317 2008-07-13 21:17 vimrc
-rw-r--r-- 1 root root 665 2008-01-31 04:52 vimrc.tiny
I am using ubuntu
You just have to create the .vimrc file either under /root or /home/xxx/
In case someone else happens to browse to this page...
I am running Ubuntu 8.10. when I added .vimrc to my home directory, it didn't change the behavior of vim.
However, I did find
/etc/vim/vimrc
and uncommented the "syntax on" line (line 20) for me.
If it is not in your vimrc, just add the line. This changes syntax highlighting for every user on the system... which may be an unintended consequence, but is exactly what I needed.
Hi it is also worked for me, I am using Ubuntu 8.10;
apt-get install vim-nox
then edit as vim /etc/vim/vimrc then enable the line from " syntax on " i.e. just remove the double inverted comma <"">
then save and exit... enjoy
Thanks for reminding to change /etc/vim/vimrc
It now works for me.
thankkkkkkkuuuuuuuuuuuu...it works even for meee...
Hi i am using ubuntu 8.10. I didn't get syntax enable or syntax on. Then i try to install sudo apt-get install vim-full. when i gave enter is is showingAfter this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]?
then i press y
after this the following error I am getting. So please help me
Err http://in.archive.ubuntu.com intrepid-updates/main vim-tiny 1:7.1.314-3ubuntu3.1
Could not resolve 'in.archive.ubuntu.com'
Err http://security.ubuntu.com intrepid-security/main vim-tiny 1:7.1.314-3ubuntu3.1
Could not resolve 'security.ubuntu.com'
Err http://security.ubuntu.com intrepid-security/main vim-common 1:7.1.314-3ubuntu3.1
Could not resolve 'security.ubuntu.com'
I fully agree with whatever thing you have presented.
On Ubuntu 12.04 I ran:
sudo apt-get install vim
and did not have to edit the .vimrc file at all; syntax highlighting is enabed by default.
Post a Comment