Skip to content

Instantly share code, notes, and snippets.

@jparker
Created February 20, 2014 00:00
Show Gist options
  • Save jparker/9104192 to your computer and use it in GitHub Desktop.
Save jparker/9104192 to your computer and use it in GitHub Desktop.
Vim mappings for executing Ruby or Python
" note the trailing white space on the next line
noremap <Leader>pe :!python %
noremap <Leader>px :!python %<CR>
" note the trailing white space on the next line
noremap <Leader>re :!ruby %
function! RunFile()
if match(@%, '.rb$') != -1
let argv = input('!ruby % ')
exec '!ruby % ' . argv
elseif match(@%, '.py$') != -1
let argv = input('!python % ')
exec '!python % ' . argv
else
echo '<< ERROR >> RunFile() only supports ruby and python'
endif
endfunction
noremap <Leader>rx :call RunFile()<CR>
noremap <Leader>rx :!ruby %<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment