The VIM syntax highlighting method under Linux

Source: Internet
Author: User
Tags printf

Highlight Label *tag-highlight*

If you want to highlight all the tags in the file, you can use the following mappings.

   --Generate the Tags.vim file and highlight the label.

   --Highlight tags only based on existing tags.vim files.

: Map : SP tags :%s/^ ([^:]*:) = ([^]*). */syntax keyword TAG 2/ : wq! Tags.vim /^

: Map : So Tags.vim

Warning: The longer the label file, the slower it will be, and the more memory the Vim consumes.

The typedef is only highlighted here, and it can be set for union and struct. To do this, you need to exuberant ctags (can be found in http://ctags.sf.net).

Put the following line in your Makefile:

# Create a types highlighting file. Need exuberant Ctags and awk

Types:types.vim

Types.vim: *. [CH]

ctags-i=gstus-o-*. [CH] |

awk ' begin{printf ("syntax keyword Typet")}

{printf ("%s", $$1)} End{print ""} ' > $@

Put the following line in your. VIMRC:

"Load Types.vim highlighted file, if present

Autocmd Bufread,bufnewfile *. [CH] Let fname = expand (' :p: H '). '/types.vim '

Autocmd Bufread,bufnewfile *. [CH] If filereadable (fname)

Autocmd Bufread,bufnewfile *. [CH] exe ' so '. FName

Autocmd Bufread,bufnewfile *. [CH] endif

==================================================

The above F11 can only recognize definitions within functions, function names, etc., and cannot recognize macro definitions.

Change yourself into

"Generate the highlighted file according to tags file tags.vim

Map : SP tags : Set Nohls :%s/file/fi le/ :%s/^ ([^:]*:) = ([^]*). */syntax keyword TAG 2/ : wq! Tags.vim /^

"All the tags in the highlighted file

Map : So Tags.vim

You'll be able to recognize macros.

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.