Document directory
- Background
- Basic knowledge
- Preparations
- Custom themes
- My themes
- Summary
Manually expand the vim plug-in-color
By Ma Dongliang (cream Loki)
One man's war (http://blog.csdn.net/MDL13412)
Background
Anyone who has used a slightly improved editor knows that you can customize the font color, background color, and keyword color in settings to improve our development efficiency. For an editor like vim, of course, these functions are indispensable. I will show you the flexibility beyond the reach of other editors below.
There are thousands of VIM theme plug-ins on the vimcolorschemetest site. However, each theme has something we are not satisfied with. Therefore, we need to expand it ourselves. This article is my experience in customizing the vim topic and I would like to share it with vimer.
Basic knowledge
- In vim, themes also exist in the form of plug-ins. The built-in themes are stored in$ Vimruntime/colorsFolder*. VimName. (Note: View$ VimruntimeRun: Echo $ vimruntime)
- User-defined themes are generally not placed in the system directory, but in~ /. Vim/colorsDirectory.
- Run the following command to change the vim topic:
: Colorscheme theme plug-in name
- But in this way, only the vim topic can be changed temporarily, and the change will be restored after exiting. If you want to change it permanently, go ~ /. Add the following to vimrc:
Colorscheme theme plug-in name
Preparations
Because I do not use gvim in windows, but use Vim in Linux or remote SSH~ /. VimrcTo enable 256 color support:
set t_Co=256
To highlight keywords when editing a program~ /. VimrcEnable syntax highlighting:
syntax enablesyntax on
After completing the above preparations, let's officially start the theme customization journey!
Custom themes
Theme tones
Before configuring other attributes, you must first configure the overall color of the subject. There are only two options: Dark and Light (dark and bright ). For programmers who frequently read and write code, dark colors are a better choice:
set background=dark
Next, you need to reset the syntax highlighting, otherwise the setting will not take effect:
if version > 580 hi clear if exists("syntax_on") syntax reset endifendif
Topic name
The topic name is called without parameters.: ColorschemeThe returned information is used to distinguish different topics. The settings are as follows:
let g:colors_name="nslib_color256"
Basic Attributes
Vim can run on the black and white terminals, color terminals, and GUI. Therefore, we need to configure the decibels. The following is a brief description:
Properties of term black and white terminal properties of cterm color terminal properties of ctermfg color terminal foreground color ctermbg color terminal background color GUI properties guifg GUI foreground color guibg GUI background color
We do not need to configure the black and white terminals. Therefore, the main configuration is focused on the Color terminal and GUI interface. Because the configuration of the color terminal and GUI interface is only different in keywords, therefore, only color terminals are selected here for description.
Because not all terminals support 256 colors, using some security colors will make our theme more portable, and GUI can support all colors, which is not within the scope of consideration. The security colors provided in the vim document are as follows:
"0 Black "1 DarkBlue "2 DarkGreen "3 DarkCyan "4 DarkRed"5 DarkMagenta "6 Brown, DarkYellow "7 LightGray, LightGrey, Gray, Grey "8 DarkGray, DarkGrey "9 Blue, LightBlue "10 Green, LightGreen "11 Cyan, LightCyan "12 Red, LightRed "13 Magenta, LightMagenta "14 Yellow, LightYellow "15 White
Color Matching syntax
The following example illustrates the color scheme Syntax:
hi Type ctermfg=LightYellow ctermbg=Black cterm=bold
Where,HiYesHighlightThe abbreviation of the command, used to highlight the configuration;TypeIs the name of the element to be colored; the parameter usesKey = Value.
Element list
The syntax for color configuration is very simple and does not need to be cumbersome. The following describes the commonly used element tags for classification:
Status Bar prompt information
Hi statusline status bar Hi statuslinenc non-current window status bar errormsg error information warningmsg warning information modemsg current mode moremsg other text question ask the user error Error
Text Search
Text string matching in hi incsearch incremental search
Pop-up menu
Pmenu pop-up menu pmenusel menu current selection item
Form border
Vertsplit Vertical Split Window border linenr row number cursor character cursorline cursor row colorcolumn cursor column colorcolumn ruler nontext window tail ~ And @, and the characters that are not actually displayed in the text
Diff Mode
Diffadd diff mode added rows diffchange diff mode changed rows diffdelete diff mode deleted rows difftext diff mode inserted text
C/C ++ syntax
Comment comment preproc preprocessing type data type constant statement control statement special character string in special string ccppstring CPP string Number todo, hack, fixme and other labels
My themes
Configuration File
set background=darkif version > 580 hi clear if exists("syntax_on") syntax reset endifendiflet g:colors_name="nslib_color256" hi Normal ctermfg=Grey ctermbg=Black hi ColorColumn ctermfg=White ctermbg=Grey ·hi ErrorMsg term=standout hi ErrorMsg ctermfg=LightBlue ctermbg=DarkBlue hi WarningMsg term=standout hi WarningMsg ctermfg=LightBlue ctermbg=DarkBlue hi ModeMsg term=bold cterm=bold hi ModeMsg ctermfg=LightBlue ctermbg=Black hi MoreMsg term=bold ctermfg=LightGreen hi MoreMsg ctermfg=LightBlue ctermbg=Black hi Question term=standout gui=boldhi Question ctermfg=LightBlue ctermbg=Black hi Error term=bold cterm=bold hi Error ctermfg=LightBlue ctermbg=Black ·hi LineNr ctermfg=LightBlue ctermbg=Black hi CursorColumn ctermfg=White ctermbg=Grey hi CursorLine ctermfg=LightBlue ctermbg=Black hi ColorColumn ctermfg=White ctermbg=Grey ·hi IncSearch ctermfg=Black ctermbg=DarkGrey hi Search ctermfg=Black ctermbg=DarkGrey hi StatusLine term=bold cterm=bold hi StatusLine ctermfg=Black ctermbg=Grey hi StatusLineNC term=bold cterm=bold hi StatusLineNC ctermfg=Black ctermbg=Grey ·hi VertSplit ctermfg=Grey ctermbg=Grey hi Visual term=bold cterm=bold hi Visual ctermfg=Black ctermbg=Grey ·highlight Pmenu ctermfg=Black ctermbg=Grey highlight PmenuSel ctermfg=LightBlue ctermbg=DarkBlue ·hi Comment ctermfg=DarkCyan ctermbg=Blackhi PreProc ctermfg=Blue ctermbg=Blackhi Type ctermfg=LightYellow ctermbg=Black cterm=boldhi Constant ctermfg=Blue ctermbg=Black cterm=boldhi Statement ctermfg=LightYellow ctermbg=Black cterm=boldhi Special ctermfg=Red ctermbg=Black cterm=boldhi SpecialKey ctermfg=Red ctermbg=Black cterm=boldhi Number ctermfg=Blue ctermbg=Blackhi cCppString ctermfg=Red ctermbg=Blackhi String ctermfg=Red ctermbg=Blackhi Identifier ctermfg=Red ctermbg=Black cterm=boldhi Todo ctermfg=Black ctermbg=Gray cterm=boldhi NonText ctermfg=LightBlue ctermbg=Blackhi Directory ctermfg=Blue ctermbg=Blackhi Folded ctermfg=DarkBlue ctermbg=Black cterm=boldhi FoldColumn ctermfg=LightBlue ctermbg=Blackhi Underlined ctermfg=LightBlue ctermbg=Black cterm=underlinehi Title ctermfg=LightBlue ctermbg=Blackhi Ignore ctermfg=LightBlue ctermbg=Blackhi Directory ctermfg=LightBlue ctermbg=Blackhi browseSynopsis ctermfg=LightBlue ctermbg=Blackhi browseCurDir ctermfg=LightBlue ctermbg=Blackhi favoriteDirectory ctermfg=LightBlue ctermbg=Blackhi browseDirectory ctermfg=LightBlue ctermbg=Blackhi browseSuffixInfo ctermfg=LightBlue ctermbg=Blackhi browseSortBy ctermfg=LightBlue ctermbg=Blackhi browseFilter ctermfg=LightBlue ctermbg=Blackhi browseFiletime ctermfg=LightBlue ctermbg=Blackhi browseSuffixes ctermfg=LightBlue ctermbg=Blackhi TagListComment ctermfg=LightBlue ctermbg=Blackhi TagListFileName ctermfg=LightBlue ctermbg=Blackhi TagListTitle ctermfg=LightBlue ctermbg=Blackhi TagListTagScope ctermfg=LightBlue ctermbg=Blackhi TagListTagName ctermfg=LightBlue ctermbg=Blackhi Tag ctermfg=LightBlue ctermbg=Black
Summary
Vim is highly flexible and can be configured with options that cannot be configured by other editors. It is very suitable for people like me who like it :-)