Monday, December 10, 2007

Colors in vi

So after turning off the colors in the 'ls' command on linux, I also had to deal with the colors using vi...
When reading a logfile for example, the file is presented in 5 or 6 different colors..
To turn off these colors edit the following file (as root)...

/usr/share/vim/vim60/macros/vimrc

In this file you will see the following lines:

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 has("gui_running")
syntax on
set hlsearch
endif

You can disable coloring by placing " in front of these lines..

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
"if &t_Co > 2 has("gui_running")
" syntax on
" set hlsearch
"endif

Now all colors are gone, and I believe reading is much easier ....

1 comment:

Anonymous said...

You may also want to disable the colours on a user by user basis instead of globally. To accomplish this, create or edit the .vimrc file in the users' home directory and add the following lines at the end:

"turn off all syntax highlighting
syntax off
"turn off highlighting during a search
set nohlsearch

This will also make upgrading vim easier as you won't have to remember to edit the global vimrc file when the vim package is updated.