Saturday, May 1, 2010

Re: Problem with VIM syntax coloring

On 01/05/10 18:01, peterv6 wrote:
>
> I am having a problem with a vim color file. It colors everything the way I
> want it, except for Braces. I set this color file as the default to use in
> my .vimrc file. When I go in to edit a file, say a java file, however,
> everything colorizes perfectly, but the braces, brackets, curly brackets,
> and parenthesis don't color. To get them to color, I have to run the color
> command with the appropriate color filename. Can anyone help me out with
> this? I'm assuming it's a syntax error in the color file. The file is:
>
> " peterv0.vim - Vim color file
> 2 " Last Change: 2010 May 01
> 3 "
> 4 set background=dark
> 5 hi clear
> 6 if exists("syntax_on")
> 7 syntax reset
> 8 endif
> 9 let g:colors_name = "peterv0"
> 10 "
> 11 syn match Braces display '[{}()\[\]]'
> 12 hi Braces ctermfg=yellow
> 13 "
> 14 hi Cursor ctermfg=black ctermbg=white
> 15 hi CursorLine cterm=underline,bold ctermbg=black ctermfg=yellow
> 16 hi DiffAdd ctermbg=blue ctermfg=black
> 17 hi DiffChange ctermbg=darkGreen ctermfg=black
> 18 hi DiffDelete ctermbg=cyan ctermfg=black
> 19 hi DiffText ctermbg=lightGreen ctermfg=black
> 20 hi ErrorMsg ctermfg=lightRed
> 21 hi FoldColumn ctermbg=gray ctermfg=black
> 22 hi Folded ctermbg=yellow ctermfg=black
> 23 hi IncSearch ctermfg=black ctermbg=darkYellow
> 24 hi LineNr ctermfg=cyan
> 25 hi ModeMsg ctermfg=yellow
> 26 hi MoreMsg ctermfg=yellow
> 27 hi NonText ctermfg=lightMagenta
> 28 hi Normal ctermfg=white ctermbg=black
> 29 hi Search ctermfg=white ctermbg=red
> 30 hi StatusLine cterm=bold ctermfg=white ctermbg=LightGreen
> 31 hi StatusLineNC ctermfg=black ctermbg=blue
> 32 hi Todo ctermfg=black ctermbg=darkYellow
> 33 hi Underlined ctermfg=cyan cterm=underline
> 34 hi VertSplit ctermfg=blue ctermbg=blue
> 35 hi Visual ctermfg=black ctermbg=darkCyan term=reverse
> 36 hi WarningMsg ctermfg=cyan
> 37 hi cIf0 ctermfg=gray
> 38 hi comment ctermfg=Magenta
> 39 hi constant ctermfg=cyan
> 40 hi identifier ctermfg=red
> 41 hi label ctermfg=yellow
> 42 hi operator ctermfg=lightGreen
> 43 hi preproc term=underline ctermfg=LightBlue
> 44 hi Special ctermfg=lightMagenta ctermbg=DarkGreen
> 45
> 46 hi statement ctermfg=green
> 47 hi title cterm=bold
> 48 hi type ctermfg=lightRed ctermbg=None
>
> I'd really appreciate help with this.
>

The place for a ":syn match" command is not in a colorscheme (which is
only sourced once, when the ":colorscheme" command is issued, and maybe
again if you set ":syntax on" after using "syntax off"), but in a syntax
script (which is sourced every time a file of the concerned filetype is
opened). If you want to apply that Braces synmatch to all files, then
you might add to your vimrc the following (untested)

if has('autocmd') && has('syntax')
au VimEnter * au Syntax * syn match Braces display '[]{}()[]'
endif

while keeping the Braces highlight command in your colorscheme.
Otherwise that :syn match command should go (I think) in
~/vimfiles/after/syntax/whatever.vim (on Windows), or
~/.vim/after/syntax/whatever.vim (on Unix), replacing "whatever" by the
syntax type (which is usually the filetype).


Best regards,
Tony.
--
I have great faith in fools -- self confidence my friends call it.
-- Edgar Allan Poe

--
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: