2

\a is equivalent to [A-Za-z] so it matches only non-accented letters.

I know of [=name-of-equivalence-class=], so I can clearly use something like \(\a\|[[=a=][=e=][=i=][=o=][=u=]]\), but I was wondering whether there was a more fundamental solution, such as an option to automatically match every element of the equivalance class for each character in the pattern.

The reason why I would have expected a less hand-crafted solution is that other options doing something similar exist, such as \c/\C and \Z.

I haven't found anything in :help pattern.

1
  • 3
    The trouble is that not all accented characters are composites. à is U+00e0 but is U+0061 + U+0300: [=a=] and \Za match the latter but not the former. Handling both scenarios would mean doing what [=…=] and \Z do, plus matching against all the single character variants of those pairs.
    – romainl
    Commented Jun 4, 2023 at 7:07

1 Answer 1

1

I've discovered the \k character class, which matches anything that is in 'iskeyword', which can in turn be set iskeyword=@, where the meaning of @ is explained at isfname:

If the character is '@', all characters where isalpha() returns TRUE are included. Normally these are the characters a to z and A to Z, plus accented characters.

Which is precisely what I need.

So one way to accomplish the task is to use \k instead of \a and set iskeyword=@ when the behavior described in the question is needed, e.g. when entering search mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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