Search code examples
vimsyntax-highlightingvim-syntax-highlighting

Improved CSS syntax highlighting in vim


The CSS syntax highlighting in vim is not entirely optimal. For example:

div.special_class

stops the highlighting at the _.

Is there an improved highlighter that doesn't bite on an underscore?

Update: I'm using VIM - Vi IMproved 7.1 (2007 May 12, compiled Jun 17 2008 15:22:40)

and the header of my css.vim is:

" Vim syntax file
" Language:     Cascading Style Sheets
" Maintainer:   Claudio Fleiner <claudio@fleiner.com>
" URL:          http://www.fleiner.com/vim/syntax/css.vim
" Last Change:  2006 Jun 19
" CSS2 by Nikolai Weibull
" Full CSS2, HTML4 support by Yeti

Solution

  • I don't have that problem. This is the header of my syntax file:

    " Vim syntax file
    " Language: Cascading Style Sheets
    " Maintainer:   Claudio Fleiner <claudio@fleiner.com>
    " URL:      http://www.fleiner.com/vim/syntax/css.vim
    " Last Change:  2007 Nov 06
    " CSS2 by Nikolai Weibull
    " Full CSS2, HTML4 support by Yeti
    

    The relevant line of the syntax file, is this:

    syn match cssClassName "\.[A-Za-z][A-Za-z0-9_-]\+"