VIM + csinsight build source insight in Linux

Source: Internet
Author: User

Source insight is the most convenient tool for viewing code in windows. However, source insight does not have a Linux version. To facilitate code browsing and learning in Linux, we can use vim and csinsight to build the source insight in Linux.

Cscope is a tool and plug-in suitable for VIM. With cscope, you can easily learn the definition of a function and which functions are called.

 

Cssag Installation

You can download the source code package at http://cscope.sourceforge.net/, decompress it, and compile and install the package.

./Configure

Make

Make install

 

Generate a cssag Database

Before using cssag, you must generate a cssag database for the code. If the current code is in the/usr/src/Linux directory, run the following command.

CD/usr/src/Linux

Cs1_rbq

Then, three files are generated: csexample. In. Out, csexample. Out, And csexample. Po. Out.

Use Vim to open the code file and import the generated cscope file to VIM.

Vim init/Main. c

: CS Add/usr/src/Linux/csout. Out/usr/src/Linux

You can also add the following statement to the vim configuration file. vimrc.

if fileradable("cscope.out")    cs add csope.outelseif $CSCOPE_DB  != ""    cs add $CSCOPE_DBendif

 

Cssag Functions

Cssag is implemented through its Sub-command "find.

CS find c | d | E | G | f | I | S | T name

  • S: Find the C Code Symbol
  • G: search for this definition
  • D: Find the function called by this function.
  • C: Find the function that calls this function.
  • T: search for this string
  • E: Find the current egrep mode.
  • F: Find this file
  • I: Find the file that contains this file

You can add the following shortcut keys in. vimrc to avoid entering a long string of commands every time.

nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>nmap <C-@>f :cs find f <C-R>=expand("<cword>")<CR><CR>nmap <C-@>i :cs find i ^<C-R>=expand("<cword>")<CR>$<CR>nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>

When used, move the cursor over the object to be searched, and press <c-@> G, that is, press Ctrl + @, and then press g soon ", the object definition will be searched.

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.