Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).
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[]
- 14 Highlight all search pattern matches
- 24 Changing the default syntax highlighting
- 25 Color highlighting on telnet
- 53 Better colors for syntax highlighting
- 99 Identify the syntax highlighting group used at the cursor
- 111 Printing with syntax highlighting independent of your normal highlighting
- 121 Using vim as a syntax-highlighting pager
- 126 Syntax highlighting in xterm
- 172 Using Ispell on a highlighted region
- 206 Highlight doubled word errors in text
- 235 Highlight current word to find cursor
- 269 Refresh out-of-sync syntax highlighting
- 284 Print syntax highlighted buffer in one color
- 396 Highlighting whitespaces at end of line
- 421 The simplest map to highlight the current line
- 449 Fortran highlighting problems
- 454 Fix syntax highlighting so it keeps working
- 572 Auto highlight current word when idle
- 621 Vim as a syntax highlighting engine for web publishing
- 639 Highlight debug blocks in programs
- 641 Highlighting of method names in the definition
- 744 Get latest releases for syntax highlighting, runtime, plugins etc
- 754 Highlighting source between matching curly braces
- 769 Highlight current line
- 810 Highlight long lines
- 857 Different syntax highlighting within regions of a file
- 941 Adding MPI and PVM syntax highlighting
- 969 Highlight simple Python syntax errors
- 1017 Highlight text inside matching parentheses
- 1120 Remove annoyance with syntax highlighting when starting a string
- 1141 List lines with current search pattern highlighted
- 1152 Improved version of Highlight Matching Paren
- 1174 Syntax highlighting for LJ and html-enabled web forums
- 1193 Syntax highlighting for HTML with embedded Javascript
- 1274 Highlight some whitespace characters
- 1279 Highlight current line using cursorline
- 1293 Highlight the current line in the active window
- 1380 Highlight cursor line after cursor jump
- 1381 Highlight special filetype docs
Tips relating to color schemes[]
Also see 53, 111, 284 (listed above).
- 178 Create a color scheme based on another
- 231 Localized color schemes
- 341 Switch color schemes
- 955 Easily switch between two styles of color scheme
- 1036 Change the color scheme
- 1291 Desert color scheme with Vim in PuTTY
- 1305 Define your own colors
- 1312 256 colors in vim
- 1576 Using vim color schemes with Putty
- 1619 Using GUI color settings in a terminal
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.