I have commentted out all of my vimrc file, in my macOS (22.6.0 Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64 arm Darwin
), it cannot find tag with the folloing commands and source
$ cat x.lua
function test ()
end
$ ctags -R x.lua
$ cat tags
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
test x.lua /^function test ()$/;" f
$ vim -t test
# vim reports the error like "E257: cstag: Tag not found"
If I removed the space after the function name test
, like function test()
, then it could work.
I also test this in my EC2 ubuntu, it could work even tough there is a space after the function name test
.
I dont know how to debug after this, I also asked it to ChatGPT 3.5, but it could not resolve this.
When parsing your file, ctags
created a test
tag, note the trailing space, not a test
tag. This is probably because the default parser for Lua doesn't expect optional whitespace between the name of the function and the opening parenthesis.
Since the actual tag is test
, a search for test
with -t test
or :tag test
won't work because the search is literal. You would have to…
test
, with the space, in Vim: :tag test
,test
: :tag /test
inside Vim, or:
test
from your shell: $ vim -t /test
.See :help tag-regexp
.
If you can't remove that extraneous space from your code, which would be the real solution, here, you can tell ctags to search for new tags with a bit of regexp (see $ man ctags
) or try Universal Ctags, as mentioned in the comments, which might or might not be smarter than Exuberant Ctags in this particular scenario.