Skip to content

Instantly share code, notes, and snippets.

@ironcamel
Created September 15, 2011 04:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ironcamel/1218566 to your computer and use it in GitHub Desktop.
vim script runner
nmap <F5> :call Run('perl')<CR>
cabbrev pyx call Run('python')
cabbrev perlx call Run('perl')
cabbrev rubyx call Run('ruby')
fu! NewThrowawayBuffer()
new
setlocal noswapfile
setlocal buftype=nowrite
setlocal bufhidden=delete
endf
fu! Run(cmd)
only
%y
call NewThrowawayBuffer()
wincmd J
resize 15
put
exe "%!" . a:cmd
0 read !date
append
----------------------------
.
wincmd w
endf
@ironcamel
Copy link
Author

This vim plugin lets you execute any script you are editing in vim and the output is displayed in a split window at the bottom. I have included mappings for perl, python and ruby. As you can see, it is easy to add your own mappings for other languages. With the mappings above, you could for example execute a perl script via the command :perlx or by hitting F5 in normal mode.

To install, just drop this file in your $HOME/.vim/plugin folder. Or you could append it to your .vimrc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment