Would setting match_word for if/elsif/else be a good fit for vim-perl?

75 views
Skip to first unread message

HarleyPig

unread,
Jul 12, 2013, 8:03:06 PM7/12/13
to vim-...@googlegroups.com
I have

let b:match_words = '\<if\>:\<elsif\>:\<else\>'

in my after/ftplugin/perl.vim file for use with the matchit plugin.

Would this be a good fit for vim-perl's ftplugin file?  If so, I'll make a pull request.

On a related note, does anyone have other match_words settings they use for perl?

Andy Lester

unread,
Jul 14, 2013, 10:30:34 PM7/14/13
to vim-...@googlegroups.com

On Jul 12, 2013, at 7:03 PM, HarleyPig <alansy...@gmail.com> wrote:

> I have
>
> let b:match_words = '\<if\>:\<elsif\>:\<else\>'
>
> in my after/ftplugin/perl.vim file for use with the matchit plugin.

I'm wary of embedding support for other plugins into vim-perl. The vim-perl files are what ship with vim to every vim user.

xoa

--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance

Benjamin Fritz

unread,
Jul 15, 2013, 11:58:31 AM7/15/13
to vim-...@googlegroups.com
On Sun, Jul 14, 2013 at 9:30 PM, Andy Lester <an...@petdance.com> wrote:
>
> On Jul 12, 2013, at 7:03 PM, HarleyPig <alansy...@gmail.com> wrote:
>
>> I have
>>
>> let b:match_words = '\<if\>:\<elsif\>:\<else\>'
>>
>> in my after/ftplugin/perl.vim file for use with the matchit plugin.
>
> I'm wary of embedding support for other plugins into vim-perl. The vim-perl files are what ship with vim to every vim user.
>

Yes, but the matchit plugin also ships with Vim for every Vim user.
I'd support this inclusion.
Many ftplugin files distributed with Vim have support for matchit.
vimgrep for b:match_words in $VIMRUNTIME/ftplugin currently gives 108
results on my install.

Andy Lester

unread,
Jul 15, 2013, 12:02:27 PM7/15/13
to vim-...@googlegroups.com

On Jul 15, 2013, at 10:58 AM, Benjamin Fritz <fritzo...@gmail.com> wrote:

Yes, but the matchit plugin also ships with Vim for every Vim user.

Well, then, by all means post a patch posthaste.  I'm about to send a batch of stuff off to Bram.

Rob Hoelz

unread,
Jul 15, 2013, 1:08:36 PM7/15/13
to vim-...@googlegroups.com, an...@petdance.com
I feel like this might belong in the contrib/ directory. Not because
matchit isn't widespread enough (there's actually logic for it in
vim-perl), but because some users may not want this functionality.

-Rob

HarleyPig

unread,
Jul 16, 2013, 2:01:58 PM7/16/13
to vim-...@googlegroups.com, an...@petdance.com
On Monday, July 15, 2013 11:08:36 AM UTC-6, Rob Hoelz wrote:
I feel like this might belong in the contrib/ directory.  Not because
matchit isn't widespread enough (there's actually logic for it in
vim-perl), but because some users may not want this functionality.

Matchit code is already in vim-perl, in ftplugin/perl.vim at line 84 which is why I felt safe in making the suggestion.

Pull request made.

Rob Hoelz

unread,
Jul 16, 2013, 2:14:10 PM7/16/13
to vim-...@googlegroups.com, alansy...@gmail.com, an...@petdance.com
Right, but the matchit logic in ftplugin/perl.vim is to fix the behavior
of % when used in Perl's special string forms. This behavior is
supposed to be unsurprising to users of perl.vim, because it simply
helps % match braces better. Your proposal adds new
behavior to %, which some users may not find desirable. That's why I
think it belongs in contrib/.

-Rob

HarleyPig

unread,
Jul 16, 2013, 2:19:04 PM7/16/13
to vim-...@googlegroups.com, alansy...@gmail.com, an...@petdance.com
On Tuesday, July 16, 2013 12:14:10 PM UTC-6, Rob Hoelz wrote:
Right, but the matchit logic in ftplugin/perl.vim is to fix the behavior
of % when used in Perl's special string forms.  This behavior is
supposed to be unsurprising to users of perl.vim, because it simply
helps % match braces better.  Your proposal adds new
behavior to %, which some users may not find desirable.  That's why I
think it belongs in contrib/.

I see your point ... and even agree with it a little bit.  I can't really come up with counter-arguments though, so it may be that you are correct ... 

Andy Lester

unread,
Jul 19, 2013, 12:29:42 PM7/19/13
to vim-...@googlegroups.com

On Jul 16, 2013, at 1:14 PM, Rob Hoelz <r...@hoelz.ro> wrote:

Right, but the matchit logic in ftplugin/perl.vim is to fix the behavior
of % when used in Perl's special string forms.  This behavior is
supposed to be unsurprising to users of perl.vim, because it simply
helps % match braces better.  Your proposal adds new
behavior to %, which some users may not find desirable.  That's why I
think it belongs in contrib/.


Right now, if you're on an if, and you %, it takes you to the nearest matching thing like a paren.  I'm not sure I see it as bad as making it jump to the next if/elsif/else.

Seems to me that it is MORE surprising to have a % on the "if" here

  if ( foo ) {
  } else {
  }

take me to the first paren.

Rob Hoelz

unread,
Jul 19, 2013, 4:52:48 PM7/19/13
to vim-...@googlegroups.com, an...@petdance.com
It's not bad, but it's somewhat inconsistent with Vim's notion of %
(the documentation for % specifies that it jumps to the next brace-like
character if you're not on one). I think matchit it mostly for
languages like Python/Ruby/Lua that don't use braces for block
delimiters. I'm not opposed to this idea; I just don't think we should
force it on users. I think that a language suite's job is to support
the language as well as possible without heaping too much extra
functionality on the user.

-Rob
signature.asc
Reply all
Reply to author
Forward
0 new messages