6

I'd like to match in Vim any whitespace character, not only normal space (U+0020) and tab (U+0009) with \s, and the other ASCII ones like form feed (U+000C) with [[:space:]], but any Unicode whitespace character, like e.g. NBSP (U+00A0), ENSP (U+2002), "asian space" (U+3000), etc., without listing them all in [].

One would like to match whole Unicode category (Zs), but Vim pattern syntax does not seem to support those, unlike eg. Perl (\p{}).

Equivalence class matching cannot be used as well. Eg. [[=a=]] matches all "aàá", but [[= =]] matches only ordinary space character.

Is there an elegant way to do it?

2
  • not possible with vim regular expressions May 4 at 15:53
  • What about using perl's capabilities in a vim function, or as a filter?
    – Jens
    May 5 at 6:50
2

You asked for elegant, but got no answer... so here's the non-elegant way, listing all 25 characters defined as whitespace:

\(\%u0009\|\%u000A\|\%u000B\|\%u000C\|\%u000D\|\%u0020\|\%u0085\|\%u00A0\|\%u1680\|\%u2000\|\%u2001\|\%u2002\|\%u2003\|\%u2004\|\%u2005\|\%u2006\|\%u2007\|\%u2008\|\%u2009\|\%u200A\|\%u2028\|\%u2029\|\%u202F\|\%u205F\|\%u3000\)

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.