Created
February 20, 2014 00:00
-
-
Save jparker/9104192 to your computer and use it in GitHub Desktop.
Vim mappings for executing Ruby or Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" note the trailing white space on the next line | |
noremap <Leader>pe :!python % | |
noremap <Leader>px :!python %<CR> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" note the trailing white space on the next line | |
noremap <Leader>re :!ruby % |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noremap <Leader>rx :!ruby %<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment