简体   繁体   中英

How to find offending format error in Vim tags file

I've recently seen this error whenever I hit autocomplete macros in Vim (eg ctrl-n):

E431: Format error in tags file "tags"

The tags file is generated with Exuberant Ctags and it's about 1MB. How do I find the error that's triggering this error?

我在生成的标签文件中找到了一些额外的行!_TAG_FILE_FORMAT行。当我删除这些额外的行时,vim开始工作。

The tags database is line-oriented; after the header (line(s) starting with !_TAG_FILE_... ), each line corresponds to a tag.

By using binary search , you should be able to quickly locate the offending line(s): Save a copy of the tags file, remove one half, test. If you still get the error, repeat (until you're down to one line). Else, take the other half and repeat.

This is a general troubleshooting technique; for example, it's also helpful to locate problems in Vim plugins (by disabling one half of them).

Really long function names can cause this error. You can find these functions by opening the tags file in vim and looking for method names longer than 50 chars.

/^[^\t]{50,}

I think ctags has a problem with parsing java script files. Excluding it from tagging fixed this problem for me.

ctags -R --exclude=*.js .

In addition to jaster 's answer:

I found this, which states that lines longer that 512 characters break vim: 1. Keep the text short, because: - The line length that Vi can handle is limited to 512 characters. http://ctags.sourceforge.net/FORMAT

EDIT: updated source: https://neovim.io/doc/user/vi_diff.html Maximum length of a line in a tags file: 512 bytes.

I indeed did have a tag line longer that 512 characters - removing that line fixed the issue for me.

I solved this problem by rebuilding the tags.

First remove all tags files and then rebuild tags from your project.

I think the reason was i built the tags files twice, first time the tags built for child directories, then build the parent directories.

So, the child directories tags couldn't contain some parent directories information.

I came across the same issue, seems not all file formats are well supported. I used the option -L to create tags for only c and c++ files ,the issue went away . You might want to try the following , just substitute the *.postfix with the corresponding format you need.

ctags -L $(find . -name *.c -or -name *.cpp -or -name *.h -or -name *.lua )

删除不符合ctags标准的额外行为我解决了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM