Create a tool to read Linux source code

Source: Internet
Author: User
Tags prototype definition

Create a tool to read Linux source code

Read/write code in Linux generally with VI

But reading the source code when it comes to a larger project is more laborious, always using the Find and grep commands.

In fact, we can create a reading of the source code vim, so that greatly improve work efficiency.

Read the source combination: Vi + Ctags + taglist

The following are the final implementations:

Installing Ctags

Ctags can be downloaded to http://ctags.sourceforge.net. I'm currently downloading ctags-5.8.tar.gz.

Tar-xvzf ctags-5.8.tar.gz

CD ctags-5.8

./configure

Make

Make install

You can then go to the source directory to generate the index file of Fame tags with the following command:

Ctags-r

After that, you can use the VI in this directory

Ctrl +]//Find the label under the cursor, such as a function or struct

Ctrl + t//return to the previous place before jumping to the tag file

Isn't that very convenient?

For more detailed usage of ctags, you can ctags–help or man ctags

Installing the TagList Plugin

The ZIP package I downloaded is named: taglist_45.zip

Copy it to ~/.vim/below, if there is no ~/.vim directory, you can create a new one yourself:

Mkdir-p ~/.vim/plugin

CD ~/.vim

mkdir after

mkdir colors

mkdir doc

mkdir Ftplugin

mkdir syntax

And then:

Unzip Taglist_45.zip

This will put a file in your ~/.vim/plugin and ~/.vim/doc directories:

Plugin/taglist.vim–taglist Plug-in

Doc/taglist.txt-taglist Help Files

This installs both the document and the plugin.

TagList provides quite a lot of features in my taglist.vim such configuration:

""""""""""""""""""""""""""""""

Let Tlist_show_one_file = 1 "does not display the tag of multiple files at the same time, only displays the current file's

Let Tlist_exit_onlywindow = 1 "If the TagList window is the last window, exit vim

Let Tlist_use_right_window = 1 "Displays the TagList window in the right window

Read the source code

After the configuration, feel free to open a C source file.

Enter the following command to bring up the TagList

Tlistopen

Enter the following command to turn off TagList

Tlistclose

The cursor switches between VI and TagList

Ctrl + WW (Note is two W)

In the TagList window, you can use the following shortcut keys:

<CR> jump to the position defined by tag under the cursor, double-click the tag function with the mouse

o display the cursor under tag in a newly opened window

<Space> Display the prototype definition of tag under cursor

U update tag in taglist window

s change sort mode, toggle between sort by name and sort by order

x taglist window zooms in and out to make it easier to see longer tags

+ Open a folding, with Zo

- Fold the tag together with ZC

* Open all folds, with ZR

= fold all tags together with ZM

[[ Skip to previous file ]

]] to skip to the next file

Q Close TagList window

<F1> Show Help

Create a tool to read Linux source code

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.