Friday, December 19, 2008

Ctags: whats it? N how to use!

Well, whats the use of ctags. Ctags allows you to go to the function definition from function declaration even its not defined in same file. Suppose you have a program "add.c" and there is a function "calculate( )" in it. And "calculate( )" is defined some where else. If you have ctags you can go directly to definition by pointing the cursor to function and press "shift" + "]" . You can go back by pressing "ctrl" + "t".

First of all download this package, Exuberant Ctags. If you are using Debian you can get it from synaptic.

1.Open the terminal

2.Open the directory of the file[in this case dir where add.c resides. If in /home then cd home]

3.Type ctags -R on terminal or ctags -R[space]*

4.Open program add.c [as vi add.c]

5.Type :set tags=../../tags [if you run ctags -R outside the currrent directory, else just :set tags=./tags else :set tags=../tags as where you run "ctags -R"]

Its over.. enjoy..

[PS: This solved your problem? comment if it do or not. If this is not exactly your problem, please mail me. I can help you. randeep123@gmail.com . And If you found another way to solve it, please post it.. It will help a lot of people. Thank you]

No comments: