- How To Show Line Numbers In vi / vim Text Editor
- Turn on or off color syntax highlighting in vi or vim
- Ubuntu Linux Vim Sorry, the command is not available in this version: syntax on
- UNIX / Linux: vi / vim perform search and replace operation
- FreeBSD install VIM text editor
- vi / vim Print Line Numbers on Hardcopies / Printer
- vi / vim Auto complete File Name While Editing Files
- Moving Around With vim (keyboard short cuts)
- How do I Be More Productive In Vim?
- Vim Editing Multiple Files and Windowing Support Under Linux / UNIX
Q. How do I turn on or off color syntax highlighting in vi or vim text editor under UNIX or Linux?
A. Vim or vi is a text editor. It can be used to edit all kinds of plain text. It is especially useful for editing programs or UNIX/Linux configuration files.
Task: Turn on color syntax highlighting
Open file (for example file.c):
$ vi file.c
Now press ESC key, type : syntax on
:syntax on
Task: Turn off color syntax highlighting
To turn it back off, press ESC key, type : syntax off
:syntax off
You can edit ~/.vimrc file and add command syntax on to it so that next you will start vim with color syntax highlighting option
$ cd
$ vi .vimrc
Append the following line:
syntax on
Save and close the file.
C source code editing while syntax highlighting is on in vi or vim:

Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 05/12/08



{ 16 comments… read them below or add one }
Hey this Syntax-highlighting works!!
Looks cool
Thanks.
In vim editor you can use syntax enable too.
Inside vim in command mode press shift : and write syntax press space and press tab and vim go through out different syntax command
I believe that the exact syntax is “set syntax=on”. At least that is how it works for mine.
@ Bobby, while it may work, I’m guessing you have an extra command after typing vim filename, that is because it’s asking for extra info…and can be avoided by hitting enter the correct way is:
set ts=4
set sw=4
set spell
set spl=en
syntax on
set wrap
set ai
etc….
All of the obove suggestions may not work since on most flavors of linux vi is pointing to vim. unalias vi.
$ which vi
vi=vim
$ unalias vi
$ which vi
/bin/vi
FINALLY I got syntax highlighting turned on. I had no idea how to do it. It wasn’t in the man page at all or anywhere else I had looked online until I found it here. Thanks!
For Ubuntu, you probably have the package “vim-tiny” installed by default.
To check this run:
dpkg -l vim*So install the real vim with:
sudo apt-get install vimor
sudo apt-get install vim-fullOn Debian Etch I originally just had vim-tiny, but I now have:
svn@svn:infrastructure$ dpkg -l vim*Hey Vivek,
Thanks:) it’s working!!!!!!
I am using fedora 5.My editor is VIM 6.4.7.I wanted to highlight keywords of my C program.I tried adding “syntax on” to your $HOME/.vimrc file which is copied from /usr/share/vim/vim64/gvimrc.examples…
and I tried the above mentioned tips also….pls help
Hi,
This doesn’t work in vi. any idea why? i don’t use vim and is there any setup required to use vim?
Thanks,
Senthil
Thanks, this works for me on ubuntu 8.10
It’s great! Thanks.
I am using Vim on fedora.. How do you turn off yellow highlight between space (text) in vim file?
what command turn off yellow highlight?
I turned off the colorization. Whew. Now I would like to get rid of the highlighted
matching braces. When I put the cursor on an open curley brace it highlights that
brace and the matching closing brace. Rescue me!
Titus sends
Even I had searched online a lot before but nothing worked..thankfully I landed here today and it finally worked..:) Thanks
Hey. If you are using a dark background for your terminal you may want to
” set background=dark “