1. Introduction
Cscope is a ctags-like tool, but can be thought of as an enhanced version of Ctags.
2. Installation
- sudo apt-get install Cscope
- Install by source, refer to http://blog.csdn.net/hpwzd/article/details/7405401
3. Configuration
- In the directory where the source code is located, executing CSCOPE-RBKQ will generate three files: cscope.out/csope.in.out/cscope.po.out
- Add the following paragraph in the VIMRC, where/usr/bin/cscope is the directory where the executable file is located and can be viewed through Whereis:
1 "...... ..... ..... ..... ..... ..... ..... ..... ..... ..... ..... cscope ..... ..... ..... ... .. .....2 ifHas ("Cscope")3Set csprg=/usr/bin/Cscope4Set csto=05 set CST6 Set Nocsverb7 "Add any database in current directory8 ifFilereadable ("Cscope.out")9 CS Add cscope.outTen "Else Add database pointed to by environment OneElseIf $CSCOPE _db!="" A CS Add $CSCOPE _db - endif - Set Csverb the endif - "..... cscope Replace- --------.....????????? -Nmap <[email Protected]>s:csFindS <c-r>=expand ("<cword>") <CR><CR> -Nmap <[email Protected]>g:csFindG <c-r>=expand ("<cword>") <CR><CR> +Nmap <[email Protected]>c:csFindC <c-r>=expand ("<cword>") <CR><CR> -Nmap <[email Protected]>t:csFindT <c-r>=expand ("<cword>") <CR><CR> +Nmap <[email Protected]>e:csFindE <c-r>=expand ("<cword>") <CR><CR> ANmap <[email Protected]>f:csFindF <c-r>=expand ("<cfile>") <CR><CR> atNmap <[email Protected]>i:csFindI <c-r>=expand ("<cfile>") <CR><CR> -Nmap <[email Protected]>d:csFindD <c-r>=expand ("<cword>") <CR><CR>
To use this method, press [email protected] and release press ' s ':
- [Email protected]> s----Find the C language symbol, that is, find the function name, macro, enumeration value, etc. where it appears
- [Email protected]> g----Find the location defined by functions, macros, enumerations, etc., similar to the functions provided by ctags
- [email protected]> d----Find functions called by this function
- [email protected]> c----Find functions that call this function
- [email protected]> t----Find the specified string
- [email protected]> e----Find egrep mode, equivalent to Egrep function, but the search speed is much faster
- [email protected]> f----Find and open files, like Vim's find function
- [Email protected]> i----Find the text containing this document
One thing to note is that opening the source file needs to be opened under the Cscope.out path, such as $ VI/drivers/tty/serial/imx.c instead of executing $ VI imx.cinto the serial directory. Otherwise, the cscope cannot be found.
Cscope Installation and Configuration