如何定制自己的color scheme

在vim 配置文件vimrc 中通过colorscheme 命令可以选择自己喜欢的配色方案,在vim 下输入

:colorscheme torte

既可以选择系统自带torte 配色方案,当然你也可以在vim.org 下载自己喜欢的配色方案,在debian 中用户的配色方案放置在/usr/share/vim/vim72/colors/ 目录下。每个配色方案都是一个单独的vim 文件,比如很多vim 用户喜欢用的desert.vim ,但我觉得这样的配色太花哨了,torte 更适合我。所以如果想定制自己的vim 颜色方案可以看看下面的内容。

简介

vi 和vim 都支持语法高亮,可以设置不同组词组的颜色,每个组通过设置key=value(值为颜色),key 主要有term、cterm(color terminal 有颜色终端)和GUI 三类,term、cterm、ctermbg,ctermfg,gui,guibg 和guifg 七种,bg 和fg 代表是的background 背景色和frontground 前景色。于是我们通常看到的颜色设置即为:

highlight Normal     ctermfg=Grey80   ctermbg=Black

的形式,highlight 也可以缩写为hi 。一般设置了前景色,背景色和term/gui 不设置的话,赋值为NONE。

key 对应支持的value 值如下:

term/cterm/gui       bold,reverse,italic,underline,NONE

ctermbg/ctremfg       1-256 or specific color,such as gray

guibg/guifg         any colors,#@@@@@@

推荐使用的颜色有:

Red          LightRed          DarkRed
Green        LightGreen        DarkGreen       SeaGreen
Blue         LightBlue         DarkBlue         SlateBlue
Cyan         LightCyan         DarkCyan
Magenta      LightMagenta      DarkMagenta
Yellow       LightYellow       Brown            DarkYellow
Gray         LightGray         DarkGray
Black        White
Orange       Purple            Violet

常见可用于cterm 的颜色:

*cterm-colors*

NR-16   NR-8    COLOR NAME 
0       0       Black
1       4       DarkBlue
2       2       DarkGreen
3       6       DarkCyan
4       1       DarkRed
5       5       DarkMagenta
6       3       Brown, DarkYellow
7       7       LightGray, LightGrey, Gray, Grey
8       0*      DarkGray, DarkGrey
9       4*      Blue, LightBlue
10      2*      Green, LightGreen
11      6*      Cyan, LightCyan
12      1*      Red, LightRed
13      5*      Magenta, LightMagenta
14      3*      Yellow, LightYellow
15      7*      White

常见的组有:

Comment  —-  Comments within a program

Constant  —-  Program constants, such as numbers, quoted strings, or true/false

Identifier  —-  Variable identifier names

Statement —-  A programming language statement, usually a keyword like “if” or “while”

PreProc  —-   A preprocessor, such as “#include” in C

Type    —–    A variable datatype, such as “int”

Special  —-   A special symbol, usually used for special characters like “\n” in strings

Underlined  —-  Text that should be underlined

Error  —-    Text which contains a programming language error

更多的组:

*Comment	          any comment

*Constant	any constant
String		a string constant: "this is a string"
Character	a character constant: 'c', '\n'
Number		a number constant: 234, 0xff
Boolean	        a boolean constant: TRUE, false
Float		a floating point constant: 2.3e10

*Identifier	any variable name
Function	function name (also: methods for classes)

*Statement	any statement
Conditional	if, then, else, endif, switch, etc.
Repeat		for, do, while, etc.
Label		case, default, etc.
Operator	"sizeof", "+", "*", etc.
Keyword	        any other keyword
Exception	try, catch, throw

*PreProc	generic Preprocessor
Include	        preprocessor #include
Define		preprocessor #define
Macro		same as Define
PreCondit	preprocessor    #if, #else, #endif, etc.

*Type		int, long, char, etc.
StorageClass    static, register, volatile, etc.
Structure	struct, union, enum, etc.
Typedef	        A typedef

*Special	any special symbol
SpecialChar	special character in a constant
Tag		you can use CTRL-] on this
Delimiter	character that needs attention
SpecialComment	special things inside a comment
Debug		debugging statements

*Underlined	text that stands out, HTML links

*Ignore		left blank, hidden  |hl-Ignore|

*Error		any erroneous construct

*Todo		anything that needs extra attention; mostly the
		keywords TODO FIXME and XXX

参考

  1. http://vimdoc.sourceforge.net/htmldoc/syntax.html
  2. http://www.sbf5.com/~cduan/technical/vi/vi-4.shtml
  3. http://alvinalexander.com/linux/vi-vim-editor-color-scheme-syntax

如何定制自己的color scheme》上有3条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据