Beyond the Sky

The place where surface stop and share the experience of life

vim with ctags

,

If you are c/c++ programmer and vim user, maybe know ctags. Most of the time, source code are distributed to many folders and each of them consist of numbers of .cc/.c and .h. Sometimes to search the definition of a function, class, enums etc by using "/" is inefficient. ctags allow fast jumping to function call even the function definition source code are from other directories.

apt-get install ctags


In order to use ctags, first run the command at destination directory where the source codes are located.

ctags -R *

-R is to recursively generate ctags file across certain directories. A 'tags' file will be created. If you have learn vi from vimtutor, you may know that to jump from one keyword to targeted location is to press 'ctrl ]'. Same as ctags works.

Let say when you discover a function call which you wanna see the definition, simply point the cursor to that function and press 'ctrl ]' and it will brings you there. If you wants to go back to where you came from, simply press 'ctrl t'.

Bare in mind, if the function calls are from libraries such as stdio, curses etc, you won't be able to jump to.



play dota at homevim with cscope

Write a comment

New comments have been disabled for this post.