Not using colors in vim

rafael on 2002-09-06T15:53:25

Ask writes in his weblog that he disables color markup in his editor (and gives good reasons for doing so). I don't disable it, but only because I took some time to have a color configuration that works for me. But this can raise a problem for vim users :

I'm the author of a vim script distributed with recent vims that helps to reindent perl code while typing. I find it very useful. But it doesn't function as well when syntax highlighting isn't enabled, because it looks up the current syntax group for hints on how to reindent (e.g. it doesn't perform any reindentation in the middle of a here-doc or of a POD paragraph.)

So what to do if you want smart perl indentation without perl coloring ?

Answer : revert all color groups to "Normal", as the following little vim script does :

so $VIMRUNTIME/syntax/perl.vim
redir @x
silent highlight
redir END
new
put x
v/^\(perl\|pod\)/d
%s/ xxx.*/ Normal/
%s/^/hi link /
%y x
silent @x
q!
noh
(This can be pasted into one's .vimrc. To be more extensively tested, and put somewhere else, where interested parties can find it.)