Wednesday, February 25, 2009

How To Generate Ctags and Configure It To Use With Vim (Vi Improved)?

Many of you wondering how to generate ctags and configure it to use with Vim? Here, you at the right place.

What is ctags?

According to ctags sourceforge.

Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A tag signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).

Tag generation is supported for the following languages:

Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL, Eiffel, Fortran, Java, Lisp, Lua, Make, Pascal, Perl, PHP, Python, REXX, Ruby, S-Lang, Scheme, Tcl, Vim, and YACC.

Below is 6 (six) simple steps to generate the ctags and use it with your vim.

- you need to have unix
- you need to have vim

Notes: you can generate ctags to use in windows but I haven't tried that before.

1. Download the ctags source from

I'm using

2. gunzip and untar it.

3. run ./configure

4. run make

if 'make' does not exist in global environment. Search for it by
find / -name make 2>/dev/null

12:37:35 > /usr/ccs/bin/make

--> after make you will see .C get compile and with .o output file.

5. Generate the tags

ctags -f --recurse --langmap= --languages= --verbose

12:37:35 >
/gateways/yapywa/ctags/ctags-5.7/ctags -f tags --recurse --langmap=C++:.C.h.c.cpp.hpp --languages=C++ --extra=+q --fields=+i --verbose /gateways/yapywa/ALU_CORE

6. SET CTAGS in VIM under .vimrc

se tags=/home/yapywa/tags

No comments: