Ubuntu14.04 configuration vim and gvim highlighting, jumping and auto-completion

Source: Internet
Author: User
Tags logical operators set background

First, the environment: just installed Ubuntu14.04, this article can only guarantee to achieve the effect under Ubuntu.

Second, install the Gvim.

sudo apt-get  updatesudo apt-get install VIM-GTK

Third, custom vim and GIM syntax highlighting.

The file that controls syntax highlighting is called the language name. Vim, for example, you want to customize the C language syntax highlighting, then called C.vim.

You can create a new directory in your own root directory and configure it here so that it is only valid for one user

~/.vim/plugin  plug-  in directory ~/.vim/doc     document directory   ~/.vim/Syntax Syntax directory ~/.VIMRC   Configuration directory

But I directly modify the overall, that is, modify the

/usr/share/vim/vim74/syntax/c.vim

In the.

Copy the following append to your/usr/share/vim/vim74 (the number may vary depending on the version) in the/syntax/c.vim file:

"========================================================"Highlight all Function"========================================================SYN Match cfunction display"\<[a-za-z_][a-za-z_0-9]*\>[^ ()]*) ("me=e-2syn Match cfunction display"\<[a-za-z_][a-za-z_0-9]*\>\s* ("me=e-1Hi def link cfunction Special"========================================================"Highlight all Math Operator"========================================================"C Math OperatorsSYN Match Cmathoperator display"[-+\*\%=]""C pointer OperatorsSYN Match Cpointeroperator display"->\|\.""C Logical Operators-boolean resultsSYN Match Clogicaloperator display"[!<>]=\="syn Match clogicaloperator display"==""C bit OperatorsSYN Match Cbinaryoperator display"\ (&\| | \|\^\|<<\|>>\) =\="syn Match cbinaryoperator display"\~"syn Match cbinaryoperatorerror display"\~=""More C logical operators-highlight in preference to binarySYN Match Clogicaloperator display"&&\| | |"syn Match clogicaloperatorerror display"\ (&&\| | | \)=""Math Operatorhi def link cmathoperator ccommenthi def link cpointeroperator Operatorhi def link clogicaloperator Ccommenthi def link cbinaryoperator ccommenthi def link clogicaloperatorerror cerror

Save Exit, if you previously set syntax on in the config file as VIMRC, then you can open a C language file to realize the effect. However, the effects of vim and gvim are different.

Iv. Setting the VIMRC, that is, configuring the VIM option

Append the following text to/ETC/VIM/VIMRC, which you can also write to the ~/.VIMRC configuration directory.

Set Nocompatible AboutSet Nu $filetype on -Set history= +  -Syntax on -ColorScheme Desert ASet Autoindent +Set Smartindent theSet tabstop=4  -Set shiftwidth=4  $Set Showmatch theSet VB t_vb= theSet Ruler theSet Incsearch theSet background=Dark -Syntax enable

Delete the line number when pasting the copy. Note that all options must be before syntax enable, otherwise it will not take effect.

Save exit, the following is set up:

#去掉讨厌的有关vi一致性模式 to avoid some bugs and limitations in previous versions # display lines
#设置高亮风格 # The type number of the test file # record the number of lines of history # background using black # syntax high brightness display #vim use automatic alignment, that is, the current row of the format to apply to the next line, #依据上面的对起格式, intelligent selection of the way, for similar C language writing is very useful # The first line sets the TAB key to 4 spaces, the second line sets the 4 spaces to be used when interlaced between rows # set matching mode # when Vim is editing, if the command is wrong, a sound is emitted, and the setting goes off the sound, similar to when an opening parenthesis is entered that matches the corresponding closing parenthesis # during the editing process, In the lower right corner of the status line to display the cursor position is very convenient, such as to find the book word, when input to /B, will automatically find the first # b word, when input to /Bo, will automatically find the first Bo beginning word, according to the # times, Use this setting to find the answer quickly when you find the word you want to match, don't forget to enter

V. Jump to the definition of variable function.

After configuring this function, you can use CTRL +] to jump to the definition, ctrl+t return to the original position.

5.1 See if you have Ctags installed. If not, go to http://ctags.sourceforge.net to download a package with a name similar to ctags-5.6.tar.gz.

Then unzip and compile and install:

tar -xzvf ctags-5.6. Tar . gz$ CD ctags-5.6$. /configure       //  generate Make file make makeinstall   // requires root privileges

Then go to the directory where you are developing the source code for compiling the project, executing:

$ ctags-r

will generate a tags file, using vim to open a file in your project, such as Main.c

Then execute it in vim:

    

: Set Tags=tags directory/tags

This will add tags to the vim. If you have trouble, you can put this sentence into the VIMRC mentioned above.

At this point you can CTRL +] and Ctrl+t hi skin.

Not to be continued.

Reference website:

http://blog.csdn.net/namecyf/article/details/7787479 main reference sources. There is a mistake in the code for highlighting the site, as it is rewritten in this article.

Http://blog.chinaunix.net/uid-1728743-id-24359.html offers rewriting inspiration

http://www.cnblogs.com/yootime/archive/2010/09/24/1833564.html Reference Installation Gvim

HTTP://BLOG.CSDN.NET/CAOSHUMING_500/ARTICLE/DETAILS/7648169 provides VIMRC configuration

Ubuntu14.04 configuration vim and gvim highlighting, jumping and auto-completion

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.