Unicode matchpairs not possible?

25 views
Skip to first unread message

Axel Kielhorn

unread,
Jul 1, 2012, 1:27:40 PM7/1/12
to VIM Mac Mac
Hi!

I'm using:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 4 2012 19:19:42)
MacOS X (unix) version
Included patches: 1-531

The default matchpairs are:
matchpair(:),{:},[:]

I can
:set mps+=<:>

to add a new matchpair, but I can't

:set mps+=«:»
or
:set mps+=‹:›

I get
E474: Invalid argument: mps+=‹:›

Shouldn't Vim accept any unicode character?

Axel

Tony Mechelynck

unread,
Jul 3, 2012, 8:17:00 AM7/3/12
to vim_mac
It is documented under ":help 'matchpairs'":

"Currently only single byte character pairs are allowed, and they must
be different".

What is or isn't a single-byte character depends on how characters are
represented in memory (i.e. the global 'encoding' option), not on disk
(the buffer-local 'fileencoding'). If 'encoding' is set to "utf-8",
only the 128 lowest codepoints are single-byte, so you can add <:>
(0x3C 0x3E) but not «:» (0xAB 0xBB) and not ‹:› (U+2039 U+203A). If
'encoding' is set to Latin1, only the lowest 256 Unicode codepoints
can be represented in memory, each as a single byte, so in that case
you can add «:» but you cannot even represent ‹:› in memory (in any
buffer, since 'encoding' is a global option).

Best regards,
Tony.

--

Economists state their GNP growth projections to the nearest tenth of
a
percentage point to prove they have a sense of humor.
-- Edgar R. Fiedler

Axel Kielhorn

unread,
Jul 3, 2012, 12:14:55 PM7/3/12
to vim...@googlegroups.com

Am 03.07.2012 um 14:17 schrieb Tony Mechelynck:

> It is documented under ":help 'matchpairs'":
>
> "Currently only single byte character pairs are allowed, and they must
> be different".

Thanks, I somehow missed that.

Maybe I should transform » and « to >> and << while editing and convert it back when writing the file. It's easier to type that way, which is another bonus.

Axel

Tony Mechelynck

unread,
Jul 5, 2012, 2:13:35 PM7/5/12
to vim_mac
Maybe you could, but in that case beware that having unpaired less-
than and greater-than signs (as in mathematics) will confuse Vim when
trying to find the mate of a << or >> marker. And of course you won't
be able to use << for "much less than" and >> for "much greater than"
or similar.

Best regards,
Tony.

--

Whom computers would destroy, they must first drive mad.
Reply all
Reply to author
Forward
0 new messages