Vim Tips Wiki

Changes: Changing the default syntax highlighting


Back to page

(Comments: let's have a syncolor tip)
(Move text unrelated to title to Highlighting.)
Line 16: Line 16:
*I want to make a few changes to the existing syntax highlighting: {{help|mysyntaxfile-add}}
*I want to make a few changes to the existing syntax highlighting: {{help|mysyntaxfile-add}}
*I want to change some of the colors from their defaults. Again, read {{help|mysyntaxfile}}
*I want to change some of the colors from their defaults. Again, read {{help|mysyntaxfile}}
{{Todo}} __NOTOC__
*I'm parking this information here, while waiting for a better solution.
*Need a tip on the <tt>:highlight</tt> command.
*Mention all the ways text can be highlighted (search, match, syntax, cursorline).
*Links to tips dealing with colors in an xterm.
*Links to tips dealing with colorscheme.
====Highlight examples====
Define two highlight groups and use them to show long lines (see [[VimTip810|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 "<tt>highlight</tt>" can be abbreviated to "<tt>hi</tt>", 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 <tt>LineTooLong</tt> group:
:hi LineTooLong
====Tips with "highlight" in name====
*[[VimTip14|14 Highlight all search pattern matches]]
*24 Changing the default syntax highlighting ''(this tip)''
*[[VimTip25|25 Color highlighting on telnet]]
*[[VimTip53|53 Better colors for syntax highlighting]]
*[[VimTip99|99 Identify the syntax highlighting group used at the cursor]]
*[[VimTip111|111 Printing with syntax highlighting independent of your normal highlighting]]
*[[VimTip121|121 Using vim as a syntax-highlighting pager]]
*[[VimTip126|126 Syntax highlighting in xterm]]
*[[VimTip172|172 Using Ispell on a highlighted region]]
*[[VimTip206|206 Highlight doubled word errors in text]]
*[[VimTip235|235 Highlight current word to find cursor]]
*[[VimTip269|269 Refresh out-of-sync syntax highlighting]]
*[[VimTip284|284 Print syntax highlighted buffer in one color]]
*[[VimTip396|396 Highlighting whitespaces at end of line]]
*[[VimTip421|421 The simplest map to highlight the current line]]
*[[VimTip449|449 Fortran highlighting problems]]
*[[VimTip454|454 Fix syntax highlighting so it keeps working]]
*[[VimTip572|572 Auto highlight current word when idle]]
*[[VimTip621|621 Vim as a syntax highlighting engine for web publishing]]
*[[VimTip639|639 Highlight debug blocks in programs]]
*[[VimTip641|641 Highlighting of method names in the definition]]
*[[VimTip744|744 Get latest releases for syntax highlighting, runtime, plugins etc]]
*[[VimTip754|754 Highlighting source between matching curly braces]]
*[[VimTip769|769 Highlight current line]]
*[[VimTip810|810 Highlight long lines]]
*[[VimTip857|857 Different syntax highlighting within regions of a file]]
*[[VimTip941|941 Adding MPI and PVM syntax highlighting]]
*[[VimTip969|969 Highlight simple Python syntax errors]]
*[[VimTip1017|1017 Highlight text inside matching parentheses]]
*[[VimTip1120|1120 Remove annoyance with syntax highlighting when starting a string]]
*[[VimTip1141|1141 List lines with current search pattern highlighted]]
*[[VimTip1152|1152 Improved version of Highlight Matching Paren]]
*[[VimTip1174|1174 Syntax highlighting for LJ and html-enabled web forums]]
*[[VimTip1193|1193 Syntax highlighting for HTML with embedded Javascript]]
*[[VimTip1274|1274 Highlight some whitespace characters]]
*[[VimTip1279|1279 Highlight current line using cursorline]]
*[[VimTip1293|1293 Highlight the current line in the active window]]
*[[VimTip1380|1380 Highlight cursor line after cursor jump]]
*[[VimTip1381|1381 Highlight special filetype docs]]
====Tips relating to color schemes====
Also see [[VimTip53|53]], [[VimTip111|111]], [[VimTip284|284]] (listed above).
*[[VimTip178|178 Create a color scheme based on another]]
*[[VimTip231|231 Localized color schemes]]
*[[VimTip341|341 Switch color schemes]]
*[[VimTip955|955 Easily switch between two styles of color scheme]]
*[[VimTip1036|1036 Change the color scheme]]
*[[VimTip1291|1291 Desert color scheme with Vim in PuTTY]]
*[[VimTip1305|1305 Define your own colors]]
*[[VimTip1312|1312 256 colors in vim]]
*[[VimTip1576|1576 Using vim color schemes with Putty]]
*[[VimTip1619|1619 Using GUI color settings in a terminal]]
I want a simple syntax highlighting which does not take attention from the real thing. Color
codes are:
:Green for comments
:Blue for keywords/types
:Bluebold for flow-control
:Brown or gray for strings and constants
:Black (or navy) for the rest
For that purpose I changed the "syncolor.vim" file (and it works best for light background xterm).
Every colleague I have shown this syntax-scheme says that it is superb - it works with your
intuition, green is definitely just something which can be ignored. I sent a mail to Bram
who answered that we have a repository for config files?
I wanted to share my syncolor with vim-users, but I cannot find the appropriate place to do so.
SynColor Comment term=bold cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=NONE guifg=MediumSeaGreen guibg=NONE
SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=SlateGrey guibg=NONE
SynColor Special term=bold cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=DarkRed guibg=NONE
SynColor Identifier term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE
SynColor Statement term=bold cterm=NONE ctermfg=Blue ctermbg=NONE gui=bold guifg=SlateBlue guibg=NONE
SynColor PreProc term=underline cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=SlateBlue guibg=NONE
SynColor Type term=underline cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=bold guifg=Blue guibg=NONE
SynColor Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue
SynColor Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE
//Donald Axel//--[[User:Donald j axel|Donald j axel]] 22:54, November 11, 2009 (UTC)
:Hi Donald, and welcome to the wiki!
:I have only a vague idea of Vim's color schemes and syntax highlighting, but I have a feeling that syncolor allows the modification of an existing color scheme (or is it to modify syntax highlighting for a particular file type?). People use a color scheme (see {{help|:colorscheme}}) to define their standard colors. Bram would have been referring to the fact that there are ''many'' color schemes available at I just added some more information to [[VimTip341|Switch color schemes]] to show how to locate a color scheme there.
:I welcome other opinions, but traditionally we would not make a "tip" of a syncolor example on the basis that scripts should be uploaded to We do have lots of scripts here, but the aim is that tips show techniques and tutorial information; simple scripts (not worth uploading to are here, but we hope they are mainly educational.
:I suppose we could have a tip on syncolor if there was something educational to say about it (it's a mystery to me – is it extending an existing scheme? replacing?) and your code could be shown as a sample. Or, you could make a user subpage to hold the script (which we would move from here to there). For example, you might make page [[User:Donald j axel/syncolor]].
:FYI we remove temporary comments such as these after a few weeks. If you have any questions, reply here, or on my talk page, or anywhere, because Fritzophrenic and I check all changes here. [[User:JohnBeckett|JohnBeckett]] 03:29, November 12, 2009 (UTC)
::Hi John: 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.
::Maybe it is hard to understand syncolor.vim differences if you do not try them. The code above is '''only''' a section of syncolor.vim. If you do not want to write programs, forget it. However maybe you can imagine the difference between a green comment and a screeming red comment. To my view, as soon as you start using red, purple or magenta the readability decreases.
::I am looking into but it seems to be mostly text-processing.
:I support the idea of a syncolor tip. 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. --[[User:Fritzophrenic|Fritzophrenic]] 15:09, November 12, 2009 (UTC)

Revision as of 08:21, April 5, 2012

Tip 24 Printable Monobook Previous Next

created 2001 · complexity intermediate · author benji · version 6.0

Here are some pointers to the Vim documentation on syntax highlighting.


Around Wikia's network

Random Wiki