Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize vim syntax highlighting under linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to achieve vim syntax highlighting under linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Highlight label * tag-highlight*

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

-- generate a 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 this will be, and the more memory Vim consumes.

Here only typedef is highlighted, and it can also be set for union and struct. To do this, you need Exuberant ctags (which can be found at http://ctags.sf.net).

Put the following line in your Makefile:

# create a highlighted file for types. Exuberant ctags and awk are required

Types: types.vim

Types.vim: *. [ch]

Ctags-i=gstuS-o-*. [ch] |\

Awk 'BEGIN {printf ("syntax keyword Type\ t")}\

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

Put the following line in your .vimrc:

"load the types.vim highlighted file, if it exists

Autocmd BufRead,BufNewFile *. [ch] let fname = expand (': PRV 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 identify the internal definition of the function, the name of the function, etc., but not the macro definition.

Change it to

"generate a highlighted file tags.vim based on tags files

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 can recognize macros.

Thank you for reading! On "how to achieve vim syntax highlighting under linux" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report