Tuesday, September 27, 2011

RE: Color Definition at VIM Invocation???

Thanks Ben, the following .vimrc file worked perfectly with my version 5.7 VIM to define additional colors not covered in the c syntax file:

set showcmd
set showmatch
set ignorecase
set incsearch
set autowrite
syntax on
set nocompatible
set tabstop=4
set textwidth=132

fun! LinkColorGroups()
highlight link cConditional VisualNOS
highlight link cRepeat VisualNOS
highlight link cStatement VisualNOS
highlight link cLabel VisualNOS
highlight link cStructure VisualNOS
highlight link cStorageClass VisualNOS
endfun

aug SetupColors
au!
au BufRead,BufNewFile * call LinkColorGroups()
aug END

The autocommand allowed the colors to be updated after the c syntax file initialized the colors. I will update to a later VIM in the near future.

Thanks for sharing your knowledge.

Ken Schmitt


-----Original Message-----
From: vim_use@googlegroups.com [mailto:vim_use@googlegroups.com] On Behalf Of Ben Fritz
Sent: Saturday, September 03, 2011 8:06 AM
To: vim_use
Subject: Re: Color Definition at VIM Invocation???

On Sep 2, 2:58 pm, "Benjamin R. Haskell" <v...@benizi.com> wrote:
> Does 5.7 have autocommands?  If so, put 'em in a function that gets
> called when editing files:

I'm pretty sure syntax highlighting has always been triggered using autocmds, so probably this will work.

>
> fun! LinkColorGroups()
>      highlight link cConditional VisualNOS
>      highlight link cRepeat VisualNOS
>      highlight link cStatement VisualNOS
>      highlight link cLabel VisualNOS
>      highlight link cStructure VisualNOS
>      highlight link cStorageClass VisualNOS endfun
>
> aug SetupColors
>      au!
>      au BufRead,BufNewFile * call LinkColorGroups() aug END
>

I'd try an autocmd like this first:

au Syntax c call LinkColorGroups

Since it's closer to what you're trying to accomplish.

But perhaps it won't work in a Vim as old as 5.7.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment