[Vim] custom syntax highlight file Vim syntax highlight Configuration

Source: Internet
Author: User
Document directory
  • Custom syntax File

In fact, sequence Vim supports the addition of syntaxes in hundreds of languages. However, the addition of scripts based on syntaxes does not satisfy everyone. Sometimes we want to highlight some specific constants. However, the configuration is required.

Just like the OpenGL I recently learned, I want to enable the system constants and functions to be highlighted when I edit files (. c files. So next we will look at how to configure our syntax file.

Vim syntax brightening mechanism

The syntax of VIM is highlighted in two parts.

  1. Syntax unit matching: determines whether a character in a text is a comment or a constant or a string. After Vim has determined the syntax unit to be highlighted, it starts to use the specified highlighted file.
  2. Highlight files based on the highlighted Script: note that Vim is not specific to a specific file at this stage. If any type of file is highlighted, the constant type is highlighted in the same color. ,
Specific Configuration
  • Custom syntax File

The syntax file is in {echo $ Vim}/vim72/syntax by default. Note: Input echo $ Vim on the Vim command line to obtain the installation path of VIM on the system.

  • Custom color files

The color configuration file is in {echo $ Vim}/vim72/colors by default. Note: Input echo $ Vim on the Vim command line to obtain the installation path of VIM on the system.

To configure a color file of your own, you can first select a color template that is close to your own, and then modify it.

You can enter colorscheme \ t in the vim command line to check the effect of the color file that comes with the system. Note: Entering the tab key will display the existing color configuration file of the system. Move the cursor to highlight the selected configuration. Press enter to check the effect. If you have a nice color file. You can write the name of the selected color configuration file in. vimrc or. gvimrc, so that the selected color configuration will be automatically loaded every time you open vim. E.g. colorscheme Ron


(To be continued)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.