2

With ignorecase set, I am able to jump to a tag Foo by typing :ltag foo. However, doing so causes the message

Using tag with different case!

to appear at the bottom of the screen, along with a ~0.5s delay during which vim does not update. The same message and delay appear when jumping to another tag (which does not match in case) with :tnext or :tprevious. This occurs even with tagcase set to ignore.

How can I prevent this from occurring? I can do so by preceding the command with silent, but this also suppresses the "tag x of y" message, which I want to keep.

4

According to my reading of the code you've found the only way to avoid that stuff: use of silent.

This appends the warning...nothing can prevent it except for disabling ignorecase et al...

if (ic)
    STRCAT(IObuff, _("  Using tag with different case!"));

Then a bit later the warning is printed and a nice one second freeze is initiated...

if (ic && !msg_scrolled && msg_silent == 0)
{
    out_flush();
    ui_delay(1000L, TRUE);
}

As you can see, the only (partial cuz you lose the rest of the message) recourse is silent.

Why so strict? I'm guessing but it may be because doing case-insensitive matching "disables binary searching" of tags and apparently relies then on a secondary, slower search method. That's according to help: scroll down about 30 lines below :h tag-priority to see what I'm talking about.

Oh yeah, I should mention the location of the above code in case someone's interested. It's in tag.c, function do_tag()...which rings in at an eye popping nearly 1000 lines...imagine a function/method of that length in, say, Python or Java. ;) Anyways, just search for the warning in that file ("Using tag with different case!").

| improve this answer | |
1

Well, it turns out there's at least one way to avoid the message:

:ltag /\cfoo

will match a tag called Foo without producing error output. (Somehow :ltag /foo with ignorecase set, which should theoretically behave the same way, still produces the warning and delay on a tag Foo.)

To make this more convenient to type, I've added the mapping

nnoremap <Leader>t :ltag /\c

to my .vimrc. The one disadvantage here is that if you want to match a tag name exactly (say you also have a tag barfoobaz, which you don't want to match), you have to either type out ^foo$ or delete the /\c and type Foo (with correct capitalization, to avoid the delay).

| improve this answer | |
  • There may be a subtle difference. If your tag files are "case-fold sorted" then matches can be found with the binary type of search when using ignorecase and a simple search term. If you use a regex, though, Vim will do a linear search. (Per help, binary search is "a LOT faster"....presumably O(log n) vs O(n) or something like that) – B Layer Jul 31 at 23:00
  • Side note: some regexes, theoretically, should not prevent a binary search. For example, one that just uses ^ (start of line anchor). Whether Vim optimizes out such things I've not checked. – B Layer Jul 31 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.