Vim use (ii) Browse the kernel source code

Source: Internet
Author: User

To achieve similar sourceinsight functionality, the Vim+ctags+cscope+taglist+source Explore +nerd tree is implemented.

One, install the plug-in

1) Install Ctags and Cscope

Ubuntu can be installed directly from the command:

sudo Install ctags cscope

Note: Cscope and ctags function similar, but can supplement ctags insufficiency, both can combine Ctags convenience, double can use cscope supplement ctags limitation, is a powerful tool of Linux kernel code analysis.

2) Install TagList:

By adding to the. VIMRC:

' Taglist.vim '
Bundle "Scrooloose/nerdtree"
Bundle "WESLEYCHE/SRCEXPL"
Bundle "Majutsushi/tagbar"

Re-execute: Bundleinstall command can be installed automatically.

3)

Second, configure and use plug-ins

The Linux kernel has a generated script for the tag database with Ctags and Cscope, and the corresponding database file can be generated in the kernel source code directory by command:

 Make Ctags  make Cscope

Note: The former generates a 92M tags file, which generates Cscope.files (the directory of Analysis files) and other file databases.

Configure the Ctags and Cscope databases with VIM linkage:

"""ctags Database Path"""""""Set Tags=/home/magc/workspace/linux-2.6.32.67/Tags"""cscope Database Path"""""""Set CSPRG=/usr/bin/cscope"Whereis cscopeSet csto=0            "cscope DB Search FirstSet CST"cscope db Tag db searchSet Nocsverb"verbose off"CS DB PathCS add/home/magc/workspace/linux-2.6.32.67/cscope.out/home/magc/workspace/linux-2.6.32.67Set Csverb"Verbos off

TagList plug-in configuration:

""""""""Tag List setting""""""""filetype Onnmap<F7>:tlisttoggle<cr>"F7 Key = Tag list togglingLet Tlist_ctags_cmd ="/usr/bin/ctags"    "Whereis ctagsLet Tlist_inc_winwidth =0        "window width change off"Let Tlist_exit_onlywindow=0Let tlist_auto_open=0            "when Vim is turned onLet Tlist_use_right_window =1

Source Explorer Plug-in configuration:

"""""""Source Explorer Setting""""""Nmap<F4>:srcexpltoggle<cr>"control+h into the left windowNmap <C-H> <C-W>h"control+j into the bottom window.Nmap <C-J> <C-W>J"control+k into the top windowNmap <C-K> <C-W>k"control+l into the right window.Nmap <C-L> <C-W>L let G:srcexpl_winheight=8"//Set ms for refreshing the Source ExplorerLet g:srcexpl_refreshtime= -"//Set"Enter"Key to jump into the exact definition contextLet G:srcexpl_jumpkey="<ENTER>""//Set"Space"Key for back the definition contextLet G:srcexpl_gobackkey="<SPACE>"Let g:srcexpl_isupdatetags=0

NERD Tree Plugin configuration:

"""" "" "" "" "" Letnerdtreewinpos= "Left"< F2>:nerdtreetoggle<cr>

Note: The shortcut keys included in the above settings are:

    • F7 Open TagList
    • F4 Open Source Explorer
    • F2 Open Nerd Tree
    • Control+h into the left window
    • Control+k into the top window
    • Control+j into the bottom window.
    • Control+l into the right window.

Vim use (ii) Browse the kernel 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.