Tags file not sorted

2,460 views
Skip to first unread message

Bob

unread,
May 21, 2010, 7:10:37 PM5/21/10
to vim_use
Ive created some tags files for our codebase here
at work. After creating the tags file I use 'sort'
and rewrite the file so its sorted, however when
tags cannot find a tag, it gives me the following
message for each of the tags files Ive created:

E432: Tags file not sorted: /tmp/web.tags
E432: Tags file not sorted: /tmp/server.tags
E426: tag not found: notarealtag

I read through vim a little and saw that I could
change something to make it linear search the
tags file, but that would take too long and is
inefficient of course.

Can someone tell me how to fix this so tags
works properly?

Thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

John Beckett

unread,
May 21, 2010, 7:43:29 PM5/21/10
to vim...@googlegroups.com
Bob wrote:
> Ive created some tags files for our codebase here at work.
> After creating the tags file I use 'sort'
> and rewrite the file so its sorted, however when tags cannot
> find a tag, it gives me the following message for each of the
> tags files Ive created:
>
> E432: Tags file not sorted: /tmp/web.tags
> E432: Tags file not sorted: /tmp/server.tags
> E426: tag not found: notarealtag

You are not supposed to 'sort' a tags file as a separate step.
Instead, you tell ctags to sort it. I haven't thought about this
for a long time, and I'm not really sure if I've configured
something clever, but just running 'ctags' on my system results
in the second line of the tags file looking like this:

!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/

Hmm. If you create the tags file using your own tool (not
ctags), perhaps you need to add that line.

John

Gary Johnson

unread,
May 21, 2010, 9:06:25 PM5/21/10
to vim...@googlegroups.com
On 2010-05-22, John Beckett wrote:
> Bob wrote:
> > Ive created some tags files for our codebase here at work.
> > After creating the tags file I use 'sort'
> > and rewrite the file so its sorted, however when tags cannot
> > find a tag, it gives me the following message for each of the
> > tags files Ive created:
> >
> > E432: Tags file not sorted: /tmp/web.tags
> > E432: Tags file not sorted: /tmp/server.tags
> > E426: tag not found: notarealtag
>
> You are not supposed to 'sort' a tags file as a separate step.
> Instead, you tell ctags to sort it. I haven't thought about this
> for a long time, and I'm not really sure if I've configured
> something clever, but just running 'ctags' on my system results
> in the second line of the tags file looking like this:
>
> !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
>
> Hmm. If you create the tags file using your own tool (not
> ctags), perhaps you need to add that line.

Another thing to think about is how 'sort' sorts your data. I've
had to set

LC_COLLATE=C

in the environment of some of the systems I work on to have 'sort'
and 'ls' use the ASCII collating sequence which I prefer.

Regards,
Gary

Tony Mechelynck

unread,
May 22, 2010, 2:02:37 PM5/22/10
to vim...@googlegroups.com
According to the help, Vim cannot use "national" collating sequences
that differ from ASCII. It can use case-folded ASCII sorting provided
that 'ignorecase' is on. It can use linear search if you :set
notagbsearch or if there is a !_TAG_FILE_SORTED header with a value of
zero. The value (0, 1 or 2) MUST be separated from the rest by exactly
one hard tab on either side. If no match is found by binary searching,
Vim will try again with a linear search, so if you expect many misses
you should avoid binary searching.


Best regards,
Tony.
--
Krogt, n. (chemical symbol: Kr):
The metallic silver coating found on fast-food game cards.
-- Rich Hall, "Sniglets"

Bob

unread,
May 28, 2010, 12:51:05 PM5/28/10
to vim_use

> > Another thing to think about is how 'sort' sorts your data.  I've
> > had to set
>
> >      LC_COLLATE=C
>

It would appear setting this environment variable fixed my issue.
To clarify my original post, I wrote a script that recusively called
ctags in each directory and just 'cat'd each tag file to one larger
file, then called 'sort' on it.

Thanks for your help!

Adam Monsen

unread,
Apr 22, 2011, 2:59:41 AM4/22/11
to vim...@googlegroups.com
Gary Johnson writes:
> Another thing to think about is how 'sort' sorts your data.
> I've had to set
>
> LC_COLLATE=C
>
> in the environment of some of the systems I work on to have
> 'sort' and 'ls' use the ASCII collating sequence which I
> prefer.

Ah, thank you! I'm trying to create my own tags files, and
this environment variable was a huge help.

Reply all
Reply to author
Forward
0 new messages