Thursday, 14 April 2011

Usefull cscope and ctags commands

cscope cmd:
1. Invoke cscope -d to launch the cscope. Make sure you already created the cscope database and exists in the current dir where this cmd is issued
2. You can use the find cmd to create cscope database files
find <path> -name “*.c” -print >> cscope.files   [ repeat this for other file ext like .h,.cpp etc]
cscope -b -q -k cscope.files    [ to build the cscope database]
3. Use tab to switch between files and search sections
4. Use Ctl+d to exit the cscope
ctags cmd:
1. Ctr+] to go to definition of symbol
2. Ctr+t to go back to previous location
3. Ctr+i , Ctr+o to toggle between the points
4. ctags -L <file list> to generate tags for all the files in the list
4. ctags -R to generate all files tags recursively (this will generate tags file)
5. set tags=./<path>/tags , ./../<path>/tags in vim to browse the code flow
VIM setup:
Create/edit .vimrc file in user home dir
set ic    -> will ignore case for search
set ts=4   -> will set tab to 4 spaces
set incsearch  -> will highlight the text as we type the search word
set hlsearch    -> highlight the all matching search words
set tags=/<path>/tags,/<path>/tags   -> set your tags path for vim, so that you don’t have to set tags every time you open the vim

More details @
http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
http://tutorial.fyicenter.com/out.php?ID=4231

No comments:

Post a Comment