Wednesday, June 29, 2011

Re: How ctags search outside current directory

On 2011-06-30, ????????? wrote:
> Hello, I'm using vim to read some project source codes, but some problem using
> ctags come to me. If my directory hierarchy is somewhat like that:
>
> ---src
> |-----thread
> |-----------Tiger
> |------device
>
> If I am in /src/thread/ and type ctags -R , then I can jump to function that in
> both the current directory and the directory named Tiger, but I cann't read
> functions that are in /src/device. That's my problem.
> If I am in the root directory, say, /src/, then type ctags -R, then switch to /
> src/thread, and use C-] try to jump to the function in /src/device, it pop the
> message: file device/timer.c does not exist. the file timer.c is where my
> jumped function stays.
>
> I want to jump to any functions with /src/, but how to realize it? can you give
> me a hand?

If you cd to some directory and execute "ctags -R", the resulting
tags file will contain path names relative to that directory, making
it difficult to use the tags when Vim is started in any other
directory. A solution to this is to give ctags the absolute path
names of the directories you wish to search. In your case, you
could execute ctags as

ctags -R /src

or as

ctags -R /src/thread /src/device

Additionally, you can specify the location for the tags file with
the -f option, e.g.,

ctags -f /src/thread/tags -R /src

and you can tell Vim where that tags file is with

:set tags=/src/thread/tags

Then it won't matter where you start Vim, it will be able to find
the tags file and the tags commands (e.g., C-]) will be able to find
the target files.

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: