[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

running ruby -p -e from vim

sean_n

6/20/2006 7:30:00 PM

For you vim users:

Because you can do a lot with just 1 line of ruby code, it seems
natural to use ruby with the -p -e options to editor text from within
an editor like vim. However, I just can't seem to figure out how to
use |v| and $&. vim seems to interpret these and i escaping them with
'\' doesn't work.

i.e. let's say i do a visual block on these lines.
the quick brown cat
the quick brown cat

And I wanted to run these commands:
:'<,'> !ruby -p -e "gsub(/cat/) {|v| puts v}
:'<,'> !ruby -p -e "gsub(/cat/) {|v| puts #{$&}}

how do i escape the characters to prevent vim from interpreting them?

1 Answer

Dumaiu

6/21/2006 4:48:00 PM

0

Never tried Ruby with Vim, but I should. It looks like you are
trying in your example to call gsub() without a receiver. From reading
`:help ruby`, I'd say you would have much better luck using Vim's
embedded Ruby API. `:version` should list '+ruby' somewhere in its
output. If it doesn't, let us know and we'll go from there.

-J