A suitable theme is crucial for Vim’s writing.

Vim’s default theme is pretty generic. You can easily find a lot of themes on Vim Colors, but most of them are in a state of disrepair, not that they don’t work, but that the author hasn’t maintained them for a long time, and the language highlighting and support is not perfect.


The downloaded theme, xxx.vim, is placed in the Colors folder under the Vim directory so that vim will be preloaded when it starts. Alternatively, you can manage the theme as a plugin for Vundle.


First, we recommend a few popular Vim themes here:

1. Solarized (Solarized/vim-colse-solarized at master · altercation/ Solarized · GitHub)

Is a popular theme, very famous, each major IDE have this theme color matching style, the main advantage of the theme is tonal eye protection, support is also very comprehensive, the author has continued to update, at the same time support most of the mainstream plug-in highlighting. Disadvantage is too popular, has been rotten streets, and no characteristics.

2. Gruvbox (Github-Morhetz/Gruvbox: Retro Groove Color Scheme for Vim)

Rookie theme, foreigners by modifying Solarized income. Solarized was almost reconstructed by the author. The advantage of this theme is that it supports almost all the major Vim plug-ins on the market, and the color matching is comfortable and refreshing.


3. Badwolf (Github-SJL/Badwolf: A Vim color scheme.)

Yes, the famous author of the Gundo plugin, but Gundo seems to have fallen into disrepair and is now using a different version maintained by foreigners. But that doesn’t take away from the theme which is very, very good. The downside is that the HTML color scheme is somewhat arbitrary.





4. Codeschool (Github-antlypls/VIm-colors-codeschool: Codeschool color theme for Vim)

Vim for Ruby on Rails (and a sexy Theme!) (via @AstonJ)

Cool color series theme, theme overall color matching is good, but the disadvantage is that the support for many plug-ins is not comprehensive.

How to write a theme?

Not satisfied with any of the above topics? Haven’t found your theme yet? It doesn’t matter. Do it yourself. Feed yourself.

It is important to understand that the ColorScheme in Vim, the theme, is actually a plug-in as well. It is written as a plug-in, and the API uses Vim’s Highlight and other interfaces.


The first step is to create a theme

You need to go to the colors folder in the vim directory and create a theme file, name it whatever you want, and the extension must be already

.vim

At the end.

Add code:

"Highlight Clear" if exists("syntax_on") "reset syntax reset endif set background=dark" Theme style set to dark let G :colors_name="hellovim" "Set the theme name to hellovimCopy the code


So, how do we add highlighting after that? First, you must understand what the Vim theme highlights. There are two main functions:

hi Normal guifg=#990808 guibg=black ctermfg=255 ctermbg=20 gui=bold cterm=none

hi link Mystyle Normal
 
Copy the code

The first line:

Hi Style name GUIFG =Gvim font color GUIBg =Gvim Background color CTERmfg = Terminal Vim font color CTERMBg = Terminal Vim background color GUI =Gvim font style Cterm = Terminal Vim font styleCopy the code

Hi means highlight, which is the abbreviation. Normal means initialization style, Normal style, GUIFG means, in GVim (Vim with GUI), the font color is #990808, and GUibg means the background color is black, Ctermfg represents the font color matching in VIM’s Terminal under Linux. Terminal only has 256 colors, so to be specific, you need to query the 256 color value table to see what color each number represents. The final GUI cterm represents the font style. You can set it to bold(bold) or None (general). Here is the color table:




The second line:

Hi Link child style inherits from the parent style

Link’s main function is to make Mystyle inherit Normal’s color scheme. Let Mystyle have the same style as Normal. There’s no need to repeat highlight. Changing Normal also affects Mystyle.


Vim has many style names, typesetting order according to personal preferences can refer to the specific source code:

Codeschool source – >

Suggest the need to write style friends can look at a few styles of source, and then begin, as for how to detect the style name, I later update = =. Sorry ~ ~


Write in the back: also like Vim friends, if you have good articles, you can private message me, of course, not I will publish, but I invite you to column writing, Building this column oh ~