Let's talk about using ctags and csags to read code on fedora.
Source: Internet
Author: User
Let's talk about how to use ctags and csags on fedora to view the code-Linux general technology-Linux programming and kernel information. The following is a detailed description. The vim version I installed on fedora6 is 7.0 with support for ctags-5.6 and cscope-15.5. I chose a work machine to use linux fedora6. The system's built-in word and PDF file software are available, and the mail sending and receiving software is also available, which is very convenient and easy to use, that is, you need to configure the software you want to check the code for yourself. However, after configuration, the speed and usage habits are better than those of sourceinsight. Based on the experience of some people on the Internet, I have put it into practice. writing this document may help people who want to know about ctags and CSWs.
Many programmers prefer to use the vi editor on linux, and some prefer to use emacs. However, I personally prefer vi, but I do not like the editor on windows when I use vi, in fact, the reason is very simple: using the keyboard to complete the search and replacement is more accurate and faster than using the mouse, while vi uses the keyboard operation to implement the function. Currently, vim is an editor similar to vi. It is an open-source project with more functions, and ctags and csags are its plug-ins. The following describes how to configure ctags and csags For vim to view code.
1. Download and install
Taglist is a vim plug-in used to display the global variables and function names of codes in a window on the left of the screen.
Some application code is c ++, so code in. cpp format is listed to generate a cssag database.
3. Configure the. vimrc File
The vimrc content is as follows:
Set cst
Set csto = 1
Set cscopequickfix = s-, c-, d-, I-, t-, e-, f-
Cs add/home/yangxl/readcode/cscope-kernel/csnel. out
Cs add/home/yangxl/readcode/cscope-app/cscope. out
Let Tlist_Enable_Fold_Column = 0
Let Tlist_WinWidth = 30
Let Tlist_Show_One_File = 1
Set tabstop = 4
Nmap : Cs find d = Expand (" ")
Nmap : Cs find c = Expand (" ")
Nmap : Cs find t = Expand (" ")
Nmap : Cs find e = Expand (" ")
Nmap : Cs find f = Expand (" ")
Nmap : Cs find I = Expand (" ")
Nnoremap : TlistToggle
The bottom lines define shortcuts for the F2-F9 feature
F9 is the shortcut to open and close the taglist window on the left
Its syntax is explained in vi by typing
: Help cscope
Learning and understanding
4. Usage
Use vi to open the training code and press ctrl-] on the method to be called. Is the prototype code of this method displayed? Press F9 to open the Left window, display the method name list, macro definition, and global variables, and then press F9 to disappear from the Left window.
Show loaded Databases
: Cs show
We can see that two csexample. out files are loaded.
: Cs find 2 method name or: cs find d method name corresponds to the shortcut key F2
Locate the name of the method called by this method
: Cs find 3 method name or: cs find c method name corresponding to the shortcut key F3
Find the method name to call this method
: Cs find 4 string name or: cs find t string name corresponding to the shortcut key F4
Find the string that appears
: Cs find 7 file name or: cs find f file name corresponding shortcut key F7
Find File
: Cs find 8 file name or: cs find I file name corresponding shortcut key F8
Find the file that includes this file
: TlistToggle corresponds to the shortcut key F9
5. Not done
Consider how to synchronize the cssag library when the code is constantly being written?
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