Matchit and parentheses

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Matchit and parentheses

Nikolai Weibull-11
Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
advantage of our knowledge of the language to skip parentheses and
braces and so on inside comments?

  nikolai

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Doug Kearns
On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> advantage of our knowledge of the language to skip parentheses and
> braces and so on inside comments?

Seems like a good idea.

Hmmm, it doesn't seem to work for me though...

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Nikolai Weibull-11
On 5/1/06, Doug Kearns <[hidden email]> wrote:
> On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> > Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> > advantage of our knowledge of the language to skip parentheses and
> > braces and so on inside comments?
>
> Seems like a good idea.
>
> Hmmm, it doesn't seem to work for me though...

 let b:match_words =
    \ '\%(' .
    \     '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(class\|module\|begin\|def\|case\|for\|do\)\>'
.
    \   '\|' .
    \     '\%(\%(^\|\.\.\.\=\|[\,;=([<>~\*/%!&^|+-]\)\s*\)\@<=\%(if\|unless\|until\|while\)\>'
.
    \ '\)' .
    \ ':' .
    \ '\%(' .
    \     '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<\%(else\|elsif\|ensure\|when\)\>' .
    \   '\|' .
    \     '\%(\%(^\|;\)\s*\)\@<=\<rescue\>' .
    \ '\)' .
    \ ':' .
    \ '\%(\%(\.\|\:\:\)\s*\|\:\)\@<!\<end\>' . ',{:},[:],(:)'

works for me.

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Doug Kearns
On Mon, May 01, 2006 at 11:36:36AM +0200, Nikolai Weibull wrote:
> On 5/1/06, Doug Kearns <[hidden email]> wrote:
> > On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> > > Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> > > advantage of our knowledge of the language to skip parentheses and
> > > braces and so on inside comments?
> >
> > Seems like a good idea.
> >
> > Hmmm, it doesn't seem to work for me though...

<snip>
 
> works for me.

So the commented ']' is skipped?

[1,
  # ]
  2,
  3,
  4]

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Nikolai Weibull-11
On 5/1/06, Doug Kearns <[hidden email]> wrote:

> On Mon, May 01, 2006 at 11:36:36AM +0200, Nikolai Weibull wrote:
> > On 5/1/06, Doug Kearns <[hidden email]> wrote:
> > > On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> > > > Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> > > > advantage of our knowledge of the language to skip parentheses and
> > > > braces and so on inside comments?
> > >
> > > Seems like a good idea.
> > >
> > > Hmmm, it doesn't seem to work for me though...
>
> <snip>
>
> > works for me.
>
> So the commented ']' is skipped?
>
> [1,
>   # ]
>   2,
>   3,
>   4]

No.  The commented '}' is skipped.

{ a => 1,
  b => 2 # Set b to 2 }
}

The "[...]" don't match up because matchit.vim doesn't escape the '[' and ']'...

I'll email Benji about it.

  nikolai

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Nikolai Weibull-11
On 5/1/06, Nikolai Weibull <[hidden email]> wrote:

> On 5/1/06, Doug Kearns <[hidden email]> wrote:
> > On Mon, May 01, 2006 at 11:36:36AM +0200, Nikolai Weibull wrote:
> > > On 5/1/06, Doug Kearns <[hidden email]> wrote:
> > > > On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> > > > > Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> > > > > advantage of our knowledge of the language to skip parentheses and
> > > > > braces and so on inside comments?
> > > >
> > > > Seems like a good idea.
> > > >
> > > > Hmmm, it doesn't seem to work for me though...
> >
> > <snip>
> >
> > > works for me.
> >
> > So the commented ']' is skipped?
> >
> > [1,
> >   # ]
> >   2,
> >   3,
> >   4]
>
> No.  The commented '}' is skipped.
>
> { a => 1,
>   b => 2 # Set b to 2 }
> }
>
> The "[...]" don't match up because matchit.vim doesn't escape the '[' and ']'...

I'm thinking too much.  Just escape the '[' and ']' metacharacters and
it works fine.

  nikolai

_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|

Re: Matchit and parentheses

Doug Kearns
In reply to this post by Nikolai Weibull-11
On Sun, Apr 30, 2006 at 02:31:56PM +0200, Nikolai Weibull wrote:
> Why not add ",(:),{:},[:]" to the end of b:match_words so that we take
> advantage of our knowledge of the language to skip parentheses and
> braces and so on inside comments?

Done.

Regards,
Doug
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel