Configure Vim text color

Source: Internet
Author: User

Because I have been using the VC + VC assistant for development in windows, so I have long been used to the syntax highlighting and Automatic completion, so I am a little uncomfortable in VIM development, therefore, we want to slightly change the development environment so that it is closer to VC.

 

Before discussing the following content, make sure that vim and corresponding plug-ins are installed on your Linux. If no installation is available, see my other article:

Install the Linux development environment (VIM + ctags + taglist + cs.pdf + cppcomplete + global)

 

After entering vim, you will find that the background is black. Although the syntax is highlighted, it is very different from that in VC. Next we will adjust the color to make us look more comfortable.

 

After installing vim, you can find the vim configuration file under/etc/. The file name is vimrc and open it. It is all the initial configurations of vim, however, we may not be able to find a color-related configuration from the beginning to the end.

Of course you can't find it, if you haven't set the color before. Let's add a color and try adding color Murphy or colorscheme Murphy to the end.

Save the file and use Vim to open a source code file. Alternatively, you can enter any of the above statements in VIM command line mode. See what the effect is. Maybe you will ask, what is Murphy?

 

Don't worry. Next let's look at another directory.

CD/usr/share/Vim/vim72/colors

Ls

What do you see? Is there many *. in the vim file, there is the Murphy we just entered. Now I don't say you actually know. What is the Murphy we just entered, it is a configuration file not included in the colors directory. vim file name. If you still want to know what the word means, you don't need to check it. I tell you, it's potato, it's potato, It's tomato. Next, you may want to try the color scheme corresponding to each configuration file by using the command we used just now.

 

Next we will study, in fact, the following are some combinations of different Vim color schemes. You can open these files to see the actual content. If you have tried all the color schemes and none of them make you feel satisfied, then you should change your satisfaction. How can we do this?

 

First, find a configuration file of your favorite color scheme, such as morning. Vim, and copy it. Open it.

We can modify the color and pay attention to the following lines:

Hi normal ctermfg = black ctermbg = grey guifg = black guibg = grey98

Hi commnet...

Hi statement...

Hi type...

Hi number...

 

Let's start with the first line listed here.

Hi stands for highlight, short for light.

Normal refers to the text, which is normal refers to normal text.

Ctermfg refers to the foreground color of VIM running in terminal mode.

Ctermfg refers to the background color when Vim is running as a terminal.

Guifg refers to the foreground color of VIM running in Gui mode.

Guibg refers to the background color when Vim runs in Gui mode.

 

As we are talking about starting Vim on the terminal, I only pay attention to the second and second bits, and ignore the fourth and fifth bits.

The format of the following line is similar to that of the first line. If a term field is added, We will ignore it for the moment. Here, we need to pay attention to what the second field represents. The meanings of these fields are listed below:

CommentAny comment
ConstantAny constant
StringA String constant: "This is a string"
CharacterA character constant: 'C', '/N'
NumberA number constant: 234, 0xff
BooleanA boolean constant: True, false
FloatA floating point constant: 2.3e10

IdentifierAny variable name
FunctionFunction Name (also: Methods for classes)

StatementAny statement
ConditionalIf, then, else, endif, switch, etc.
RepeatFor, do, while, etc.
LabelCase, default, etc.
Operator"Sizeof", "+", "*", etc.
KeywordAny other keyword
ExceptionTry, catch, throw

PreprocGeneric Preprocessor
IncludePreprocessor # include
DefinePreprocessor # define
MacroSame as define
PreconditPreprocessor # If, # else, # endif, etc.

TypeInt, long, Char, etc.
StorageclassStatic, register, volatile, etc.
StructureStruct, union, Enum, etc.
TypedefA typedef

SpecialAny special symbol
SpecialcharSpecial character in a constant
TagYou can use ctrl-] on this
DelimiterCharacter that needs attention
SpecialcommentSpecial things inside a comment
DebugDebugging statements

UnderlinedText that stands out, html links

IgnoreLeft blank, hidden

ErrorAny erroneous construct

TodoAnything that needs extra attention; mostly
Keywords todo fixme and XXX
For more details, see:

Http://vimdoc.sourceforge.net/htmldoc/syntax.html

 

By referring to the above content, you can change the configuration file to what we want and save and exit.

 

Let's go back to/etc/vimrc and open it. For example, the configuration file we just changed is my_conf.vim. In the last line, add the following content:

Color my_conf

Save and exit. Open Vim again to see the results of our changes.

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.