running ruby -p -e from vim

running ruby -p -e from vim

Post by seannakas.. » Thu, 22 Jun 2006 05:05:53



For you vim users who execute ruby commands:

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 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?

 
 
 

running ruby -p -e from vim

Post by dfeus.. » Thu, 22 Jun 2006 05:15:39



> For you vim users who execute ruby commands:

> 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 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?

Are you leaving out a closing '"' in two lines above?

--
Using OpenBSD with or without X & KDE?
http://dfeustel.home.mindspring.com

 
 
 

running ruby -p -e from vim

Post by Stachu 'Dozzie' K » Thu, 22 Jun 2006 05:19:44



Quote:> For you vim users who execute ruby commands:

> 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.

Nope. It seems latural to use Ruby from within Vim _directly_.
Personally I use a lot of Perl and have Perl interpreter compiled into
my Vim, so I use ":perldo" instead of "!perl -e".

And it's comp.unix.shell, not comp.editors.

Quote:> However, I just can't seem to figure out how to
> use |v| and $&.  vim seems to interpret these and 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 #{$&}}

#v+
/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file

shell returned 2

E485: Can't read file /tmp/v836567/7
Press ENTER or type command to continue
#v-

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

--
Feel free to correct my English
Stanislaw Klekot
 
 
 

1. can't run ps command: ps: getexecname() failed

Hi All

I am new to solaris. I installed Solaris 9.  I am logged on as root
If I run ps command then it gives me following error:
ps: getexecname() failed

I tried to fun vfstab command then it gave me permission error. I
changed the permission for /etc/vfstab to 755 and when I ran the
command I got the following error.

# vfstab
vfstab: fd: cannot execute
vfstab: /dev/dsk/c0t0d0s1: cannot execute
vfstab: /dev/dsk/c0t0d0s0: cannot execute
vfstab: /dev/dsk/c0t0d0s3: cannot execute
vfstab: /dev/dsk/c0t1d0s0: cannot execute
vfstab: /dev/dsk/c0t1d0s6: cannot execute
vfstab: /dev/dsk/c0t1d0s7: cannot execute
vfstab: /dev/dsk/c0t1d0s3: cannot execute
vfstab: /dev/dsk/c0t1d0s4: cannot execute
vfstab: /dev/dsk/c0t0d0s4: cannot execute
vfstab: /dev/dsk/c0t1d0s1: cannot execute
swap: getexecname() failed

any idea?

thanks
Ali

2. spell, spellprog, etc

3. Does AIX PS/2 1.2 run on the PS/2 Models 90 and 95?

4. error making zImage

5. VIM: Is this a bug of "vim" ?

6. Data takes much more space on Linux

7. VIM ques: Using mouse for copy & paste in vim

8. vim not running on FreeBSD 3.0

9. ruby build fails segmentation fault

10. What's everyone's opinion about Ruby?

11. Ruby GTK Problems

12. Help request for Ruby 1.8 configuration, large file environment