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