Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created October 30, 2010 14:10
Show Gist options
  • Save jugyo/655329 to your computer and use it in GitHub Desktop.
Save jugyo/655329 to your computer and use it in GitHub Desktop.
" Eval line
function! EvalLine() range
let str = ""
for i in range(a:firstline, a:lastline)
let str = str . getline(i) . "\n"
endfor
ruby << EOF
require 'stringio'
$stdout = StringIO.new
begin
result = eval(VIM.evaluate('str')).inspect
rescue Exception => e
result = e.class.name
end
unless $stdout.string.empty?
result = $stdout.string
end
result.split(/\n/).reverse_each do |line|
$curbuf.append VIM.evaluate('a:lastline').to_i, line
end
EOF
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment