Vim + Ctags + csags build the source insight in linux

Source: Internet
Author: User

Recently, when I write code in linux, I always need to check the definition and call relationship. It is inconvenient to switch to source insight in windows every time, so I tried ctags + cs.pdf. I only want to quickly view the definition of variables and structures and the call relationship of functions. Therefore, it is easy to use. I omit the concept introduction and use it directly: Following the GNU standard, [cpp]. /configure make install three steps simplify the use of ctags and csags installation in two steps: 1. generate the ctags and cssag database files. 2. run the command to search for and index the ctags database file: [cpp] ctags-R. In this case, a ctags file is generated in the current directory where the command is executed, and vim is enabled, view the content and you will understand the principle of ctags to generate the cssag database file: [cpp] cssag-Rbq generates three files in the current directory, cssag. in. out cscope. out cscope. po. for ctags, you only need to remember four shortcuts: tags {ID} to jump to the tag ID: tags display tag stack CTRL-] Jump to the tag under the current cursor (equivalent to S In I ctrl + =) The CTRL-T jumps to an earlier tag in the tag stack (equivalent to ALT + <in SI) for cscope I just need to remember two Commands: c: find the function d that calls this function: Find the function called by this function for ease of use. Add the following code to vimrc: [cpp] nmap <C-\> g: cs find g <C-R> = expand ("<cword>") <CR> nmap <C-\> c: cs find c <C-R> = expand ("<cword>") <CR> in use, press CTRL + \ as the prefix to enter the command mode, press c to view the function that calls this function, and press d to view the function called by this function. In addition, I am a very lazy person, and I don't want to repeatedly comment on bashrc, add command alias, and implementation method: [cpp] alias haha = 'ctags _ cscope_func 'After ctags_cscope_func () {ctags-R cs1_- Rbq} source ~ /. Bashrc can generate the index database file by entering the command haha only once.

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.