How to view header files and library functions in VIM __ function

Source: Internet
Author: User

Vim View header file, library function method:

1, the simplest way is to install the corresponding library of the man Manual, directly in the terminal man XXX (function) such as man printf will see PRINGF related information, this method is simple and display a lot of information, if your English must pass. This approach is not the point here.

Install one of the most basic documents sudo apt-get install Manpages-dev

2, this approach allows you to better understand the header file or kernel source structure

(1) First install a tool Ctags:sudo apt-get install Ctags

Let's go into/usr/include or your kernel directory to do the following: Ctags-r *, which recursively generates a name tags tag file for each subdirectory in the current directory, which can be done after the first time.

Now as we execute vim-t printf we'll see that we've entered Vim's editing interface and also to the printf statement. or directly into the VIM edit interface Input: Tag < function name or macro > Press the TAB key to match the pattern, and continue to tab to match the next.

But what you find may not be the one you want, and how to solve the problem.

(2) To solve the above problems need to install a tool cscope:sudo apt-get install cscope

The above tools alone are not very large, but the combination of functions is very powerful. I have a vim script of my own, and it's not a lot to copy other people's functions, but it's enough.

Create a new. vimrc file in the user directory to add the following content to the file:

Set mouse=a
        let tlist_use_right_window=1
         let tlist_file_fold_auto_close=1
         map:tlisttoggle
        noremap:make
         noremap:make Clean;make
         Noremap:tlist
        noremap:tlistsync
         noremap:!. /vitags.sh:cs Reset
        noremap:!cvs up
         nnoremap @= (foldclosed (Line ('. ')) < 0)       ' zc ': ' Zo ')

If has ("Multi_byte")
Set Encoding=utf-8
Set Fileencoding=chinese
Set Fileencodings=ucs-bom,utf-8,chinese
endif
Set Wrap
Set Hlsearch
FileType plugin on

ColorScheme Elflord
Syntax on

Set NOCP
FileType plugin on
FileType indent on

If has ("Cscope")
Set Csprg=/usr/bin/cscope
Set csto=0
Set CST
Set Nocsverb
"Add any database in current directory"
If Filereadable ("Cscope.out")
CS Add Cscope.out
"Else add database pointed to by environment
ElseIf $CSCOPE _db!= ""
CS Add $CSCOPE _db
endif
Set Csverb
Set Cscopetag
endif

Set Nu
Set ts=4
Set sw=4

Set RU
Set HLS
Set is
Set SM
Set CIN
Set Cino=:0g0t0 (SUS

Set Autoread "Read open files again when changed outside Vim
Set Incsearch "Use incremental Search
Set nowrap "Do not wrap lines
Set Nobackup
Set Nowritebackup
Map:!ctags-r--c-kinds=+p--fields=+ias--extra=+q.
Map:!ctags-r.

Now try Vim-t < function name or macro, and then if you have more than one option, a list will appear to let you choose the one you need.

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.