Loading ...
Sorry, an error occurred while loading the content.

Problem with VIM syntax coloring

Expand Messages
  • peterv6
    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
    Message 1 of 5 , May 1, 2010
    • 0 Attachment
      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.

      --
      View this message in context: http://old.nabble.com/Problem-with-VIM-syntax-coloring-tp28421691p28421691.html
      Sent from the Vim - General mailing list archive at Nabble.com.

      --
      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
    • Tony Mechelynck
      ... 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
      Message 2 of 5 , May 1, 2010
      • 0 Attachment
        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
      • Peter Vanderhaden
        Tony, Thanks for the tip! I put the syn braces into the java.vim file, and it works perfectly! Peter V. ... -- You received this message from the vim_use
        Message 3 of 5 , May 1, 2010
        • 0 Attachment
          Tony,
          Thanks for the tip! I put the syn braces into the java.vim file, and it works perfectly!
          Peter V.

          On May 1, 2010, at 3:55 PM, Tony Mechelynck wrote:

          > 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

          --
          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
        • Tony Mechelynck
          ... syn match Brackets [](){}[] where [ open collection ] match closing bracket ( match opening paren ) match closing paren { match opening brace } match
          Message 4 of 5 , May 2, 2010
          • 0 Attachment
            On 02/05/10 01:31, Jack Ripper wrote:
            > Tony,
            > My first reply was too quick. I noted that the curly braces are all colored correctly, but the parenthesis and brackets still are not colored. I'm wondering if the "syntax" of the vim file might be in error. I used "syn match Brackets '[](){}'
            > Any ideas anyone?
            > Thanks,
            > Peter V.

            syn match Brackets '[](){}[]'

            where

            [ open collection
            ] match closing bracket
            ( match opening paren
            ) match closing paren
            { match opening brace
            } match closing brace
            [ match opening bracket
            ] close collection

            I'm putting the ] first and the [ last so that Vim won't confuse them
            with the enclosing [...]. The [] at the start and end are not duplicates
            of each other.


            Best regards,
            Tony.
            --
            ARTHUR: Will you ask your master if he wants to join my court at
            Camelot?!
            GUARD #1: But then of course African swallows are not migratory.
            GUARD #2: Oh, yeah...
            GUARD #1: So they couldn't bring a coconut back anyway...
            The Quest for the Holy Grail (Monty
            Python)

            --
            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
          • Tony Mechelynck
            ... Beware that you should NEVER change ANYTHING in the $VIMRUNTIME directory tree (i.e. in the $VIMRUNTIME directory or under it at any depth), because any
            Message 5 of 5 , May 2, 2010
            • 0 Attachment
              On 02/05/10 00:37, Peter Vanderhaden wrote:
              > Tony,
              > Thanks for the tip! I put the syn braces into the java.vim file, and it works perfectly!
              > Peter V.

              Beware that you should NEVER change ANYTHING in the $VIMRUNTIME
              directory tree (i.e. in the $VIMRUNTIME directory or under it at any
              depth), because any update may, and one of them sooner or later is bound
              to, remove your changes without any warning.

              If you want to modify a Vim plugin, first copy it to the same
              subdirectory of some directory early in 'runtimepath' (possibly creating
              one or more directories in the process) and apply your changes there.
              Any "well-behaved" plugin has an :if near the start, with a :finish in
              it, to avoid being run twice (or, for a non-global plugin, twice for the
              same editfile).


              Best regards,
              Tony.
              --
              Join the march to save individuality!

              --
              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
            Your message has been successfully submitted and would be delivered to recipients shortly.