Ctags: Generate tags for system header files and third-party library header files

Source: Internet
Author: User

Ctags Process System header files

Question:

When writing a program in Vim, you cannot jump to the system header file definition, and you cannot automatically write your own structure members. It needs to be solved.

Ctags are very useful in programming and browsing code using vim. You can use Ctrl +] And Ctrl + T to jump back and forth keywords.
The tags of your working directory. The simplest and most crude usage:

$ CD yourwork
$ Ctags-R *
This will generate a tags file.
However, the member variables are not included. Therefore, no prompt is displayed when the object members are automatically completed.
Solution:

$ Ctags-r -- fields = + IAS -- extra = + Q *
-Fields = [+ |-] flags
-Fields specifies the extension fields of the tags to include the tags entry.
I: inherited information: Inheritance Information
A: Access (or export) of Class Members
S: general signature information, such as the prototype or parameter table signature of routine (e.g. prototype or parameter list)
-Extra = [+ |-] flags
Specify whether to include certain extension information to the tags entry.
Q: contains information about class members (such as C ++, Java, and Eiffel ).
However, even the structure of the C language requires these two parameter settings to obtain the member information.

In this way, the structure and class members can be automatically completed.

However, system functions are not redirected. No automatic variables are completed for structures such as socket and inetaddr_in.
The simplest practice:

$ Ctags -- fields = + IAS -- extra = + q-r-f ~ /. Vim/cmdags/usr/include/usr/local/include
Then set in. vimrc

Set tags + = ~ /. Vim/cmdags
In this way, although we can basically jump to the system function definition, one problem is that some system functions are not added to the sorted AGS.
For example, the socket functions of/usr/incluce/socket. h and memset are not included in the tag:

Extern int listen (INT _ FD, int _ n) _ Throw;
This is because the macro definition of _ Throw makes ctags no longer consider this series of functions as functions.
Similarly, for example, memcpy functions:
For example

Extern int strcmp (_ const char * _ S1, _ const char * _ s2)
_ Throw _ attribute_pure _ nonnull (1, 2 ));
Attributes such as attribute_pure and nonull must be ignored. If you need the definition in # If 0, you can-if0 = yes to ignore the definition like # If 0.

$ Ctags-I _ Throw-I _ attribute_pure _-I _ nonnull-I _ attribute _ -- file-scope = yes -- langmap = C: +. H -- ages = C, c ++ -- links = yes -- c-kinds = + p -- C ++-kinds = + p -- fields = + IAS -- extra = + q-r-f ~ /. Vim/cmdags/usr/include/usr/local/include
In this way, the. Vim/cmdags file is complete, but there are too many contents. There are dozens of candidates for a function-defined jump. In this case, we can simplify the process by removing-R and specifying the directory:

$ Ctags-I _ Throw-I _ attribute_pure _-I _ nonnull-I _ attribute _ -- file-scope = yes -- langmap = C: +. H -- ages = C, c ++ -- links = yes -- c-kinds = + p -- C ++-kinds = + p -- fields = + IAS -- extra = + q-f ~ /. Vim/cmdags/usr/include/*/usr/include/sys/*/usr/include/bits /*
/Usr/include/netinet/*/usr/include/ARPA/*/usr/include/MySQL /*
You can also include some paths required for your own programming. Pay attention to the plus sign.
In this way, fewer tags are generated. There won't be too many irrelevant definitions.

On the machine, you only need to execute the following script to add the relevant directory.

========================================================== ====================================================== #! /Bin/bash # file: ctags. Sh # Author: zhankunlin # Date: 2011-11-30 # Desc: Generated System Library of ctags and tags of ACE, SQLite, and Oracle functions, stored in ~ # Mkdir-P ~ in the/. Vim/cmdags File ~ /. Vim; ctags-I _ Throw-I _ attribute_pure _-I _ nonnull-I _ attribute _ -- file-scope = yes -- langmap = C: +. H -- ages = C, c ++ -- links = yes -- c-kinds = + p -- C ++-kinds = + p -- fields = + IAS -- extra = + q-f ~ /. Vim/mongoags/usr/include/*/usr/include/sys/*/usr/include/bits/*/usr/include/netinet/*/usr/include/ARPA/ */sdb1/development/ace-5.8.0/include/*/sdb1/development/sqlite3/include/*/sdd1/Oracle/11gr2_database_x64/product/11.2.0.1.0/db_1/rdbms/public/ * printf' \ n "ctags" "==========================" set tags + = ~ /. Vim/cmdags "============================" '>> ~ /. Vimrc ================================================= ========================================================== =

 

 

Refer:

Http://hi.baidu.com/%B2%BB%D5%FD%D6%B1%B5%C4%C8%CB/blog/item/7f55080382c5a9e708fa93bf.html

From: http://abloz.com/2010/11/18/ctags-processing-system-header-files.html

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.