current directory:
[mirror@home libevent]$ ls
arc4random.c bufferevent_sock.c epoll.c event_tagging.c evutil.c l Makefile.am strlcpy-internal.h
autogen.sh buffer_iocp.c epoll_sub.c evmap.c evutil_rand.c libevent_openssl.pc.in Makefile.nmake test
b changelist-internal.h evbuffer-internal.h evmap-internal.h evutil_time.c libevent.pc.in minheap-internal.h time-internal.h
buffer.c ChangeLog evconfig-private.h.in evport.c ht-internal.h libevent_pthreads.pc.in mm-internal.h util-internal.h
bufferevent_async.c ChangeLog-1.4 evdns.3 evrpc.c http.c LICENSE poll.c whatsnew-2.0.txt
bufferevent.c ChangeLog-2.0 evdns.c evrpc-internal.h http-internal.h listener.c ratelim-internal.h whatsnew-2.1.txt
bufferevent_filter.c compat event.3 evsignal-internal.h include log.c README WIN32-Code
bufferevent-internal.h configure.in event.c evthread.c iocp-internal.h log-internal.h sample win32select.c
bufferevent_openssl.c defer-internal.h event-internal.h evthread-internal.h ipv6-internal.h m4 select.c
bufferevent_pair.c devpoll.c event_iocp.c evthread_pthread.c kqueue.c make_epoll_table.py signal.c
bufferevent_ratelim.c Doxyfile event_rpcgen.py evthread_win32.c kqueue-internal.h make-event-config.sed strlcpy.c
there some files in test directory:
[mirror@home libevent]$ ls test/
bench.c Makefile.am regress_dns.c regress_listener.c regress_ssl.c regress_zlib.c test-fdleak.c test-time.c tinytest_local.h
bench_cascade.c Makefile.nmake regress_et.c regress_main.c regress_testutils.c rpcgen_wrapper.sh test-init.c test-weof.c tinytest_macros.h
bench_http.c regress_buffer.c regress.h regress_minheap.c regress_testutils.h test-changelist.c test-ratelim.c tinytest.c
bench_httpclient.c regress_bufferevent.c regress_http.c regress.rpc regress_thread.c test-dumpevents.c test-ratelim.sh tinytest_demo.c
check-dumpevents.py regress.c regress_iocp.c regress_rpc.c regress_util.c test-eof.c test.sh
there are lots of file which have main() function in test directory:
[mirror@home libevent]$ find test/ -regex .*.c -exec grep main {} +
test/regress.c:struct testcase_t main_testcases[] = {
test/test-weof.c:main(int argc, char **argv)
test/regress_dns.c:/* FIXME: We should move this to regress_main.c if anything else needs it.*/
test/regress_buffer.c: size_t remaining;
test/regress_buffer.c: remaining = v[0].iov_len - 512;
test/regress_buffer.c: tt_int_op(remaining, ==, v[0].iov_len);
test/regress_buffer.c: remaining -= 8;
test/regress_buffer.c: n = evbuffer_reserve_space(buf, remaining+64, v, 2);
test/regress_buffer.c: tt_int_op(remaining, ==, v[0].iov_len);
test/regress_buffer.c: remaining -= 1;
test/regress_buffer.c: n = evbuffer_reserve_space(buf, remaining+64, v, 2);
test/regress_buffer.c: tt_int_op(remaining, ==, v[0].iov_len);
test/regress_buffer.c: /* Drain some of the remaining chunk, then add it to another buffer */
test/regress_main.c: { "main/", main_testcases },
test/regress_main.c:main(int argc, const char **argv)
test/regress_main.c: if (tinytest_main(argc,argv,testgroups))
test/tinytest.c:static int in_tinytest_main = 0; /**< true if we're in tinytest_main().*/
test/tinytest.c: if (!in_tinytest_main) {
test/tinytest.c: " called from within tinytest_main.\n");
test/tinytest.c:tinytest_main(int c, const char **v, struct testgroup_t *groups)
test/tinytest.c: ++in_tinytest_main;
test/tinytest.c: --in_tinytest_main;
test/test-eof.c:main(int argc, char **argv)
test/test-ratelim.c:main(int argc, char **argv)
test/tinytest_demo.c:main(int c, const char **v)
test/tinytest_demo.c: /* Finally, just call tinytest_main(). It lets you specify verbose
test/tinytest_demo.c: return tinytest_main(c, v, groups);
test/test-time.c:main(int argc, char **argv)
test/bench_cascade.c:main(int argc, char **argv)
test/test-dumpevents.c: remain in the future.
test/test-dumpevents.c:main(int argc, char **argv)
test/test-changelist.c:main(int argc, char **argv)
test/test-init.c:main(int argc, char **argv)
test/test-fdleak.c:main(int argc, char **argv)
test/bench_http.c:main(int argc, char **argv)
test/bench.c:main(int argc, char **argv)
test/bench_httpclient.c:main(int argc, char **argv)
but after i using:
ctags -R .
open vim, then
:tag main
:g ]
the status bar just shows:
E433: No tags file
E426: tag not found: main
what's wrong? the tags file is already loaded, why No tags file? it is confusing...
seems the index generated by ctags have include these files which include main function:
3643 main sample/dns-example.c /^main(int c, char **v) {$/;" f
3644 main sample/event-read-fifo.c /^main(int argc, char **argv)$/;" f
3645 main sample/hello-world.c /^main(int argc, char **argv)$/;" f
3646 main sample/http-server.c /^main(int argc, char **argv)$/;" f
3647 main sample/le-proxy.c /^main(int argc, char **argv)$/;" f
3648 main sample/signal-test.c /^main(int argc, char **argv)$/;" f
3649 main sample/time-test.c /^main(int argc, char **argv)$/;" f
3650 main test/bench.c /^main(int argc, char **argv)$/;" f
3651 main test/bench_cascade.c /^main(int argc, char **argv)$/;" f
3652 main test/bench_http.c /^main(int argc, char **argv)$/;" f
3653 main test/bench_httpclient.c /^main(int argc, char **argv)$/;" f
3654 main test/regress_main.c /^main(int argc, const char **argv)$/;" f
3655 main test/test-changelist.c /^main(int argc, char **argv)$/;" f
3656 main test/test-dumpevents.c /^main(int argc, char **argv)$/;" f
3657 main test/test-eof.c /^main(int argc, char **argv)$/;" f
3658 main test/test-fdleak.c /^main(int argc, char **argv)$/;" f
3659 main test/test-init.c /^main(int argc, char **argv)$/;" f
3660 main test/test-ratelim.c /^main(int argc, char **argv)$/;" f
3661 main test/test-time.c /^main(int argc, char **argv)$/;" f
3662 main test/test-weof.c /^main(int argc, char **argv)$/;" f
3663 main test/tinytest_demo.c /^main(int c, const char **v)$/;" f
3664 main_callback sample/dns-example.c /^main_callback(int result, char type, int count, int ttl,$/;" f file:
3665 main_testcases test/regress.c /^struct testcase_t main_testcases[] = {$/;" v typeref:struct:testcase_t
but why tag main, g ] can not locate the list of files which contain main function?
romainl's solution works for :tag name even when autochdir is enabled
i have run :set tags=./tags,tags, it works even when current dir is changed to others since autochdir is enabled, but g ] may not work sometimes, why?
but g ] not works sometimes:
the error info is E257: cstag: tag not found
Edit 2: content of .vimrc
cat ~/.vimrc
set autoindent
colorscheme desert
set number
The E433
error means that Vim didn't find your tags
file so, no, the tags file is not already loaded.
Typing :set tags
should output something like:
./tags,tags
That's the default value and it means "look for a tags
file located in the directory of the current file then in the current directory".
Because you have set autochdir
, it may happen that you end up in a directory without a tags
file. In test
, for example.
To make sure that Vim finds your tags
file, you should use something like:
set tags=./tags,tags;$HOME
It means "look for a tags
file located in the directory of the current file then in the current directory then in any parent directory up to $HOME
".
edit
Well, the setting above has worked as expected for me for a long while. But here is the little experiment I just did (with set autochdir
, of course):
I'm in ~/workspace/accordion/
that contains only one file, accordion.js
.
I do $ ctags -R .
: ~/workspace/accordion/tags
is created.
I do $ mkdir -p aa/bb/cc/dd/ee/ff
.
I do $ vim aa/bb/cc/dd/ee/ff/test.js
.
In Vim, I do :tag *mini
which jumps to the declaration of the mini()
method, member of the Accordion()
constructor located in ~/workspace/accordion/accordion.js
, as expected.
Because I've got set tags=./tags,tags;$HOME
in my ~/.vimrc
Vim correctly crawled from dir to dir until it reached ~/worspace/accordion/tags
. Even if I was quite deep in an unrealistically deep file tree.
Is there an accordion/aa/bb/cc/dd/ee/ff/tags ? no, let's go up…
Is there an accordion/aa/bb/cc/dd/ee/tags ? no, let's go up…
Is there an accordion/aa/bb/cc/dd/tags ? no, let's go up…
Is there an accordion/aa/bb/cc/tags ? no, let's go up…
Is there an accordion/aa/bb/tags ? no, let's go up…
Is there an accordion/aa/tags ? no, let's go up…
Is there an accordion/tags ? yes! let's scan it!
As another commenter asked you repeatedly without success, what is the output of :pwd
when you are in the subdirectory? Here is another request: what is the output of :call tagfiles()
?