How to find an offensive format error in a Vim tag file

I recently saw this error whenever I click on autocomplete macros in Vim (e.g. ctrl-n):

E431: Format error in tags file "tags"

A tag file is generated using Exuberant Ctags and about 1 MB. How to find the error causing this error?

+7
vim tags
source share
9 answers

Indeed, long function names can cause this error. You can find these functions by opening the tag file in vim and looking for method names longer than 50 characters.

 /^[^\t]{50,} 
+4
source share

I found some extra lines present before the line! _TAG_FILE_FORMAT in the generated tag file. When I remove these extra lines, vim will start working.

+13
source share

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

Using binary search, you can quickly find breaking lines: Save a copy of the tag file, delete one half of the test. If you still get the error, repeat (until you go down to one line). Otherwise, take the other half and repeat.

This is a general troubleshooting method; for example, it is also useful to find problems in Vim plugins (by disabling one half of them).

+4
source share

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

 ctags -R --exclude=*.js . 
+3
source share

This is fixed by generating tags for git files only.

 git ls-files | ctags --links=no --languages=javascript,java,python -L- 
+2
source share

In addition to the jaster answer :

I found this that says lines longer than 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

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

I really had a tag line longer than 512 characters - deleting this line solved the problem for me.

+1
source share

I solved this problem by restoring the tags.

First delete all tag files, and then rebuild the tags from your project.

I think the reason is that I created tag files twice, first created tags for child directories, and then created parent directories.

So, child directory tags cannot contain parent directory information.

0
source share

I ran into the same problem, it seems that not all file formats are well supported. I used the -L option to create tags only for c and c ++ files, the problem disappeared. You might want to try the following, just replace * .postfix with the format you need.

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

Removing extra lines that do not conform to the ctags standard fixes the problem for me.

-one
source share

All Articles