Vim Tips Wiki
Advertisement

This is a todo list holding miscellaneous information related to highlighting:

  • This will be a tip on the :highlight command.
  • It will mention all the ways text can be highlighted (search, match, syntax, cursorline).
  • It will have links to related items:
    • Tips dealing with colors in an xterm.
    • Tips dealing with colorscheme.

Highlight examples

Define two highlight groups and use them to show long lines (see Highlight long lines):

:highlight NearColLimit term=italic,bold cterm=italic ctermbg=yellow ctermfg=darkblue gui=bold,italic guibg=yellow guifg=darkblue
:highlight OverColLimit term=inverse,bold cterm=bold ctermbg=red ctermfg=white gui=bold guibg=red guifg=white
:syntax match NearColLimit /\%<81v.\%>77v/
:syntax match OverColLimit /\%>80v.\+/

Here is a simpler example showing that "highlight" can be abbreviated to "hi", and that you only need to define conditions that are applicable to your usage:

:hi LineTooLong cterm=bold ctermbg=red guibg=LightYellow
:match LineTooLong /\%>80v.\+/

This command shows the current settings for the LineTooLong group:

:hi LineTooLong

Tips with "highlight" in name

Tips relating to color schemes

Also see 53, 111, 284 (listed above).

Syncolor.vim

Vim 7.3 is distributed with file vim73/syntax/syncolor.vim. An example of how that file might be changed is here.

Does anyone understand what syncolor.vim is? Please add a comment with an explanation.

Some old comments provide a start:

  • The difference between color scheme and syntax highlighting is that the colorscheme affects the Vim window, syntax highlighting affects only the language elements. The two principles can clash, but Vim syncolor.vim has the excellent notion of using an "if" statement to check whether we are on a dark background or a light background.
  • There are subtle differences between a colorscheme and using syncolor, and from what I understand you should only use one or the other (though I may be wrong about that). The :help is rather cryptic on syncolor; I'd like to see some discussion of syncolor vs. a colorscheme.

References

Comments

Advertisement