Linux under Reading Source Tool (Vim + ctags+cscope)

Source: Internet
Author: User
Tags tagname

0. Write in front of the crap

The development environment has migrated to Ubuntu, and all of the tools that are handy for windows are looking for a replacement.

Windows has been using Souce Insight to read the source code, you need to find a replacement in Ubuntu.

Look at the Internet, seemingly vim + Ctags + cscope good, install to try O (∩∩) o

1. Installation

In my Ubuntu, these three software are not self-contained, need to install manually, it is easy to install with the apt-geT command

$ sudo apt-get install vim

$ sudo apt-get install Ctags

$ sudo apt-get install Cscope

Such as:

2. Use

2.1 Building an Index

Before you can search freely, you need to create an index in the root directory where you want to view the source code, that is, to execute two commands:

$ ctags-r

$ cscope-indexer-r

2.2 Using Ctag in VIM

1) jump to the specified function after entering vim, use ": Tag Func_name" to jump to function func_name. Use tag
command, you can use the TAB key to make a matching lookup and continue to press the TAB key to toggle down.
When a function has more than one definition
: Tag
Jumps to the first definition, jumps to the current file as a priority
: Tnext
Jump to the first one
: TFirst
Jump to the top count of
: [count]tprevious
Skip to Count of After
: [Count]tnext
Jump to the last one
: Tlast
You can also choose from all tagname:
: Tselect tagname

If you want to jump to an identifier that contains a block: "Tag/block" Then use the TAB key to select it. Here '/' is to tell vim
' Block ' is a statement block tag.
2) Use the "CTRL +" shortcut to jump to the definition of the function identifier where the cursor is located.
3) Use "CTRL + T" to return to the upper layer. If you want to select from an identifier that begins with Write_: Tselect/^
Write_ here, ' ^ ' represents the beginning, and similarly, ' $ ' represents the end. Multiple identifiers with the same name

2.3 Using Csope in VIM

Well, it looks like you should use Vim in Csope, if you want to build an index (cscope-indexer-r), and then execute the csope command in the source root directory.

$ csope , effects such as

Several ways to find, random input points to find content, such as i²c, press ENTER, the effect is as follows:

Select the file you want to open, enter the previous sequence number to open it in vim, and then use Ctags in vim to jump quickly between functions ^_^

Two-panel Toggle: tab

Cscope exit: Ctrl + D

4. Reference links

http://www.360doc.com/content/10/0928/13/3564483_57033907.shtml---- using vim+Ctags+ Cscope reading the source code

http://blog.csdn.net/jsufcz/article/details/3988883----- use Vim+ctags+cscope to read the source code

http://www.linuxidc.com/Linux/2011-04/34788p4.htm ------cscope (a great charm of Vim + cscope)

Linux under Reading Source Tool (Vim + ctags+cscope)

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.