mahemoff
mahemoff

Reputation: 46409

How to find offending format error in Vim tags file

I've recently seen this error whenever I hit autocomplete macros in Vim (e.g. 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?

Upvotes: 10

Views: 8292

Answers (9)

me_astr
me_astr

Reputation: 1042

Fixed it by generating tags only for git files.

git ls-files | ctags --links=no --languages=javascript,java,python -L- 

Upvotes: 2

Nick
Nick

Reputation: 11

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.

Upvotes: 1

Ma Chao
Ma Chao

Reputation: 1

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 )

Upvotes: 0

Siva Patibandla
Siva Patibandla

Reputation: 61

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

ctags -R --exclude=*.js .

Upvotes: 6

user618821
user618821

Reputation: 1

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.

Upvotes: 0

Luminator
Luminator

Reputation: 150

Removing extra lines non-comforming to the ctags standard fix the issue for me.

Upvotes: -1

jastr
jastr

Reputation: 889

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,}

Upvotes: 6

Ali
Ali

Reputation: 191

I found some extra lines present before !_TAG_FILE_FORMAT line in the generated tags file.When i remove these extra lines, vim starts working.

Upvotes: 15

Ingo Karkat
Ingo Karkat

Reputation: 172590

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).

Upvotes: 4

Related Questions