(Explanation of syntax highlighting versus colorscheme) |
(→Comments: let's have a syncolor tip) |
||
Line 141: | Line 141: | ||
::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. |
::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 vim.org/scripts but it seems to be mostly text-processing. |
::I am looking into vim.org/scripts 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 15:09, 12 November 2009
created 2001 · complexity intermediate · author benji · version 6.0
Here are some pointers to the Vim documentation on syntax highlighting.
- I want *.foo files to be highlighted like HTML files: :help new-filetype
- I want to define a syntax file for *.bar files. Read the above and also: :help mysyntaxfile
- 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
TO DO
- I'm parking this information here, while waiting for a better solution.
- Need a tip on the :highlight 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 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 (this tip)
- 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
References
Comments
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//--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 vim.org. I just added some more information to 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 vim.org/scripts. We do have lots of scripts here, but the aim is that tips show techniques and tutorial information; simple scripts (not worth uploading to vim.org) 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. 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 vim.org/scripts 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. --Fritzophrenic 15:09, November 12, 2009 (UTC)