[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: vim syntax highlight on C program files only?



On Mon, Aug 27, 2001 at 06:26:41PM -0700, Karsten M. Self wrote:
| I'm starting to play with C a bit.  Discovering some nice things in vim.
| 
| I know that there's an 'au' and 'augroup' commands, and that a number of
| vim settings can be configured using these.  I'm not sure what current
| settings exist for C program files (matching pattern *.c), or how I
| should use these settings to enable appropriate settings for programming
| support.
| 
| In particular, I'd like to enable syntax highlighting, and maybe get
| some ideas of what I should change to make things a bit more readable
| (some of my screen colors are very hard to read, particularly blue, also
| red, bolding them should help a lot).

You want something like the following :

augroup C
    au!
    au FileType c syntax on
    " You can also specify stuff like the cool auto-indenting feature
    " and a length of the lines, or tab appearance
    au FileType c set ai si cin tw=80 fo=croq
    au FileType c set ts=8 sts=4 sw=4 et
    autocmd FileType c set comments=sr:/*,mb:*,ex:*/
augroup END

For those trying to set vim properties for mail messages only, the
easiest way is with the 'mail' type, as follows :

    au! FileType mail  set tw=70 fo=tcq

Personally I prefer having a dark background an light foreground.
With gnome-terminal (or other xterms) this is set in it's config, but
for gvim the following line sets it right :

    highlight Normal guibg=black guifg=grey90

A side effect of that, as Karsten pointed out, is that much of the
syntax highlighting is dark and doesn't contrast well.  The solution
is to put :

    set background=dark  " makes syntax highlighing lighter

before calling "syntax on".  If you put it after calling "syntax on"
it will have no apparent effect.  A side effect of this, though, is if
you use a black-on-white terminal you will have a hard time seeing the
really bright colors against the white background.  If you use
"set bg=light" followed by "syn on" you can correct that situation.

HTH,
-D



Reply to: