Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[vim] Side effects of extending 'matchpairs' ?

47 views
Skip to first unread message

Janis Papanagnou

unread,
Dec 29, 2023, 11:09:33 AM12/29/23
to
When editing HTML files with Vim I pondered about extending the
'matchpairs' setting for editing convenience. The default is

matchpairs=(:),{:},[:]

For the HTML editing purpose I temporarily change that to

matchpairs=(:),{:},[:],<:>

I'd like to hear opinions about making that a fix change in the
configuration file. Or keep it an ad hoc change on demand? Could
there be any undesired side-effects I didn't think of when making
it persistent?

Janis

Eli the Bearded

unread,
Dec 30, 2023, 2:24:41 AM12/30/23
to
You can use vim's auto commands to make that happen for only HTML files
if you like.

autocmd BufNewFile,BufRead *.html set matchpairs=(:),{:},[:],<:>

Personally I stick a bunch of Unicode pairs in there, too.

https://qaz.wtf/qz/blosxom/2022/06/02/matchpairs

I keep showmatch turned off, so I don't know if the worst case is worse,
but, daily drive over a year, no issues with manual % matching.

Elijah
------
edited some of the pairs out

Janis Papanagnou

unread,
Dec 30, 2023, 1:40:16 PM12/30/23
to
On 30.12.2023 08:24, Eli the Bearded wrote:
> In comp.editors, Janis Papanagnou <janis_pap...@hotmail.com> wrote:
>> When editing HTML files with Vim I pondered about extending the
>> 'matchpairs' setting for editing convenience. The default is
>>
>> matchpairs=(:),{:},[:]
>>
>> For the HTML editing purpose I temporarily change that to
>>
>> matchpairs=(:),{:},[:],<:>
>>
>> I'd like to hear opinions about making that a fix change in the
>> configuration file. Or keep it an ad hoc change on demand? Could
>> there be any undesired side-effects I didn't think of when making
>> it persistent?
>
> You can use vim's auto commands to make that happen for only HTML files
> if you like.

Yes, I thought about making it file-type specific.

>
> autocmd BufNewFile,BufRead *.html set matchpairs=(:),{:},[:],<:>
>
> Personally I stick a bunch of Unicode pairs in there, too.
>
> https://qaz.wtf/qz/blosxom/2022/06/02/matchpairs

Interesting. And funny that the page exactly asks what I was looking
for. (BTW, thanks for the Unicode text file you linked on the page.
Very useful.)

>
> I keep showmatch turned off, so I don't know if the worst case is worse,
> but, daily drive over a year, no issues with manual % matching.

Good to know. Exactly the experience feedback I hoped for. Thanks.

I think I'll even try to make it persistent and see how it evolves.

Janis

Rene Kita

unread,
Dec 30, 2023, 2:46:14 PM12/30/23
to
I use this for C++ files, no undesired side-effects so far. It works.

Janis Papanagnou

unread,
Jan 1, 2024, 5:45:13 PMJan 1
to
This is great! - I didn't think of C++ (despite using it occasionally).

Janis

Jens Schweikhardt

unread,
Jan 1, 2024, 6:00:46 PMJan 1
to
Eli the Bearded <*@eli.users.panix.com> wrote
in <eli$23123...@qaz.wtf>:
[...]
# https://qaz.wtf/qz/blosxom/2022/06/02/matchpairs

There's a buglet,
set matchpairs=(:),[:],{:},<,>
should be
set matchpairs=(:),[:],{:},<:>

Regards,

Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

Janis Papanagnou

unread,
Jan 2, 2024, 12:13:21 AMJan 2
to
On 01.01.2024 23:45, Janis Papanagnou wrote:
> On 30.12.2023 20:46, Rene Kita wrote:
>> Janis Papanagnou <janis_pap...@hotmail.com> wrote:
>>> For the HTML editing purpose I temporarily change that to
>>>
>>> matchpairs=(:),{:},[:],<:>
>>>
>> I use this for C++ files, no undesired side-effects so far. It works.
>
> This is great! - I didn't think of C++ (despite using it occasionally).

BTW, for C++ it works also nicely on _nested_ template expressions
(like with the other three bracket types). And also Vim's brackets
operator expressions, like y3a( or d2i{ , extend the (, {, [
operations nicely on < as in c2a< .

Janis

0 new messages