Vim :ruby and :rubydo scope
Note to self. In old Vim (tested in 7.2.320), I could do this:
:ruby x='foo'
:rubydo $_=x
Now every line in the file says foo. But in Vim 7.3 I get an error:
NameError: undefined local variable or method `x' for main:Object
The scoping rules for Ruby in Vim must have changed somewhere along the line. I was abusing this feature to do some handy things, so this is sad.
A workaround is to use global variables in Ruby instead. So this still works:
:ruby $x='foo'
:rubydo $_=$x
Phew.

Speak your Mind
Preview