March 9, 2011

ctags utility - to edit/see source files in vi/vim

Dear All,

Gonna tell you about the ctags utility and how to use it in your project.
I am taking the example on Ubuntu 10.10 for C++ project

Step 1. Install ctags tool via Synaptic Manager

Step 2. To know which languages does ctags support fire the below command
ctags --list-languages --list-type
it will give you the whole list of languages for whcih cross refernce for variables, subroutines/functions etc. available use it accordingly vi/vim supports everything.

step 3. In the source directory where your Definition/Declaration files are present:

run the following command
ctags *.cpp *.h or ctags -R ( it wil recursivley generate the tag file)
you can name your own tag file  with the option -f or -o otherwise default tag file named tags would be generated.

step 4. now open any  source file  in vi / vim editor and  go to the Ex. mode(:)
type the command 'tag functionname' (the name of the function whose definition you want to look for) short form ( : ta functionname) right after this command you will be taken to the file containing the definition of the functionname there you can make the changes or go thru the definition save it (:w) or use :set autowrite feature . type : ctrl+ l or ctrl +o to come back to the original file.

for more info read man ctags:
please comment / suggest cheers!!!!!!!!!!!11enjoy:)))))))))))

Click Here!