Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Created November 19, 2012 20:35
Show Gist options
  • Select an option

  • Save thenoseman/4113709 to your computer and use it in GitHub Desktop.

Select an option

Save thenoseman/4113709 to your computer and use it in GitHub Desktop.
Executes the current ruby line when there is a # => marker at the end replacing it with the evaled result
" Executes the current ruby line when there is a # =>
" marker at the end replacing it with the evaled
" result
function! RubyExecuteLineWithMarker()
ruby << EOF
marker = '# =>'
buffer = VIM::Buffer.current
if buffer.line.match(/#{marker}/)
result = marker + ' ' + eval(buffer.line, binding).inspect
buffer.line = buffer.line.sub(/#{marker}.*/, result).chomp
end
EOF
endfunction
com! RubyExecuteLineWithMarker call RubyExecuteLineWithMarker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment