Mr.kang
Mr.kang

Reputation: 617

Character Classes in Vim

I have a question about using regexes in Vim.

When using character classes, if I search using the pattern [a-y] the search is case insensitive.

But the pattern a-z seems to make the search case sensitive.

I think it's because of the z. But I don't know why.

enter image description here

enter image description here

And I am using gVim 7.4 on Win 8.1.

enter image description here

And the character z of [a-z] is a lowercase z

enter image description here

Changing the pattern to a-Z makes the search case sensitive too.

With the pattern a-Y, strangely a 'wrong scope' error occurs.

The following images are descriptions about encoding and config.

enter image description here

enter image description here

Thanks, everyone. :)

Upvotes: 2

Views: 1384

Answers (1)

Dan Lowe
Dan Lowe

Reputation: 56657

The most straightforward answer is that in one search, case-sensitivity is on, and in the other, it is not. See :help 'ignorecase.

If that is not the case, then the only way I can reproduce this is to use a character that looks like an ASCII z but is in reality a completely different character. Among characters that resemble an ASCII z, the only one I can find that reproduces this behavior is U+0396 Greek Capital Letter Zeta: Ζ.

enter image description here

enter image description here

Even this theory is a little shaky, as this character looks like an uppercase Z, not a lowercase z - at least on my screen.

It is difficult to be certain that this is the issue given only the screenshots above and your description. More information in your question about exactly how you are entering the search characters, what encoding you are using, what your keyboard layout is, etc., might help someone write a better answer than this one.

Upvotes: 2

Related Questions