% Matching With Vim/Ruby

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

% Matching With Vim/Ruby

Scott LaBounty-3

All,

 

Not sure if this is the right list or not, but I’m trying to get matching to work (using %) in vim in a ruby file. For example if I have the following code:

 

1.upto(10) do |n|

    puts n

end

 

If the cursor is on the “do”, I’d like to hit the “%” key and have it go to “end”.

 

I have the following in an .vim/after/ftplugin/ruby.vim

 

if exists("loaded_matchit")

    if !exists("b:match_words")

        let b:match_ignorecase = 0

        let b:match_words =

                    \ '\%(\%(\%(^\|[;=]\)\s*\)\@<=\%(class\|module\|while\|begin\|until\|for\|if\|unless\|def\|case\)\|\<do\)\>:' .

                    \ '\<\%(else\|elsif\|ensure\|rescue\|when\)\>:\%(^\|[^.]\)\@<=\<end\>'

    endif

endif

 

 

which is what I had in an older system. I believe that matchit.vim is loaded already (by default).

 

Any ideas on getting this to work or alternative ways of doing this?

 

Scott


Confidentiality Statement:
This message is confidential and may contain confidential information it is intended only for the individual[s] named herein. If this message is being sent from a member of the legal department, it may also be legally privileged. If you are not the named addressee[s] you must delete this email immediately; do not disseminate, distribute or copy.

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

Re: % Matching With Vim/Ruby

Doug Kearns
On Fri, May 21, 2010 at 11:21 PM, Scott LaBounty <[hidden email]> wrote:

> All,
>
>
>
> Not sure if this is the right list or not, but I’m trying to get matching to
> work (using %) in vim in a ruby file. For example if I have the following
> code:
>
>
>
> 1.upto(10) do |n|
>
>     puts n
>
> end
>
>
>
> If the cursor is on the “do”, I’d like to hit the “%” key and have it go to
> “end”.

This works 'out of the box' with the b:match_words defined in the
distributed ftplugin.  Is there a particular reason you're redefining
it?

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

RE: % Matching With Vim/Ruby

Scott LaBounty-3

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Doug Kearns
Sent: Friday, May 21, 2010 7:05 AM
To: Vim-Ruby Devel ML
Subject: Re: % Matching With Vim/Ruby

On Fri, May 21, 2010 at 11:21 PM, Scott LaBounty <[hidden email]> wrote:

> All,
>
>
>
> Not sure if this is the right list or not, but I'm trying to get matching to
> work (using %) in vim in a ruby file. For example if I have the following
> code:
>
>
>
> 1.upto(10) do |n|
>
>     puts n
>
> end
>
>
>
> If the cursor is on the "do", I'd like to hit the "%" key and have it go to
> "end".

This works 'out of the box' with the b:match_words defined in the
distributed ftplugin.  Is there a particular reason you're redefining
it?

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

___________________________________________________________________________

Doug,

Thanks for the reply.

It didn't seem to be working out of the box (actually, I hadn't realized it should). I just removed my file and confirmed that it doesn't seem to work for me. I checked and I do have the ruby files in my /usr/share/vim/vim72 directory. Anything else I should check?

Scott


Confidentiality Statement:
This message is confidential and may contain confidential information it is intended only for the individual[s] named herein. If this message is being sent from a member of the legal department, it may also be legally privileged.   If you are not the named addressee[s] you must delete this email immediately; do not disseminate, distribute or copy.
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: % Matching With Vim/Ruby

Scott LaBounty-3


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Scott LaBounty
Sent: Friday, May 21, 2010 7:34 AM
To: Vim-Ruby Devel ML
Subject: RE: % Matching With Vim/Ruby


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Doug Kearns
Sent: Friday, May 21, 2010 7:05 AM
To: Vim-Ruby Devel ML
Subject: Re: % Matching With Vim/Ruby

On Fri, May 21, 2010 at 11:21 PM, Scott LaBounty <[hidden email]> wrote:

> All,
>
>
>
> Not sure if this is the right list or not, but I'm trying to get matching to
> work (using %) in vim in a ruby file. For example if I have the following
> code:
>
>
>
> 1.upto(10) do |n|
>
>     puts n
>
> end
>
>
>
> If the cursor is on the "do", I'd like to hit the "%" key and have it go to
> "end".

This works 'out of the box' with the b:match_words defined in the
distributed ftplugin.  Is there a particular reason you're redefining
it?

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

___________________________________________________________________________

Doug,

Thanks for the reply.

It didn't seem to be working out of the box (actually, I hadn't realized it should). I just removed my file and confirmed that it doesn't seem to work for me. I checked and I do have the ruby files in my /usr/share/vim/vim72 directory. Anything else I should check?

Scott


Doug, et al.,

I just checked and there is a matchit.vim in my /usr/share/vim/addons/plugin and /usr/share/vim/vim72/macros. Do I need to copy these elsewhere to get them to work?

Sorry for all the questions, but I haven't done a lot of vim work lately.

Scott

Confidentiality Statement:
This message is confidential and may contain confidential information it is intended only for the individual[s] named herein. If this message is being sent from a member of the legal department, it may also be legally privileged.   If you are not the named addressee[s] you must delete this email immediately; do not disseminate, distribute or copy.
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: % Matching With Vim/Ruby

Doug Kearns
On Sat, May 22, 2010 at 3:35 AM, Scott LaBounty <[hidden email]> wrote:

<snip>

> Doug, et al.,
>
> I just checked and there is a matchit.vim in my /usr/share/vim/addons/plugin and /usr/share/vim/vim72/macros. Do I need to copy these elsewhere to get them to work?

This should be sourced/loaded provided you don't have the 'compatible'
option set (it is by default) and /usr/share/vim/addons/ is in your
'runtimepath' which it presumably is although I'm not familiar with
that hierarchy.

You can test these with:

:set compatible?
:set rtp?

You can test that the matchit plugin was loaded by running

:let loaded_matchit

which should return "loaded_matchit #1" if it has been.

Now for the ruby specific b:match_words value to be set you'll need to
load the ruby ftplugin.  This is achieved with

:filetype plugin on

which turns on both filetype detection and the loading of ftplugins.

So at a minimum a vimrc containing the following should work.

set nocompatible
set rtp+=/usr/share/vim/addons
filetype plugin on

These are often provided by the system vimrc file anyway but YMMV.
What OS are you running?

> Sorry for all the questions, but I haven't done a lot of vim work lately.

No problem, ask away.

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

RE: % Matching With Vim/Ruby

Scott LaBounty-3
Doug,

It was the run time path. After I put that in, everything worked great. Thanks, I greatly appreciate the help.

Scott

Confidentiality Statement:
This message is confidential and may contain confidential information it is intended only for the individual[s] named herein. If this message is being sent from a member of the legal department, it may also be legally privileged.   If you are not the named addressee[s] you must delete this email immediately; do not disseminate, distribute or copy.
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: % Matching With Vim/Ruby

Doug Kearns
On Sun, May 23, 2010 at 3:39 AM, Scott LaBounty <[hidden email]> wrote:
> Doug,
>
> It was the run time path. After I put that in, everything worked great. Thanks, I greatly appreciate the help.

I just had a quick search for that */addons path and it would seem
you're running Debian or some derived distro?  I think you might want
to look at the vim-addons command for the Debian Way (TM) of doing
this but I'm old-school, and off to sleep, so I didn't investigate any
further. :)

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
|  
Report Content as Inappropriate

RE: % Matching With Vim/Ruby

Scott LaBounty-3
Doug,self

Yep, I'm running Ubuntu 10.04. I'll check on the vim-addons and see what I can find. I'm pretty old school myself, using vim going back to the 90's or thereabouts. I'll check out the vim-addons and see what I can find. Once again, I appreciate the help.

Scott

Confidentiality Statement:
This message is confidential and may contain confidential information it is intended only for the individual[s] named herein. If this message is being sent from a member of the legal department, it may also be legally privileged.   If you are not the named addressee[s] you must delete this email immediately; do not disseminate, distribute or copy.
_______________________________________________
vim-ruby-devel mailing list
[hidden email]
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
Loading...