This is a little off topic, but some people might find this useful. I have bindings that allow me to execute the current line or paragraph under the cursor in the underlying shell and then inject the result into the current buffer.
"execute the contents of the current line => sx
exe "nnoremap " . g:leader_prime . "x :call ExecuteCurrentLine()\<CR>"
Here leader_prime is just a second leader key I use: 's', but you could map the command however you like. ExecuteCurrentLine() is implemented as:
function! ExecuteCurrentLine()
let l:com = substitute(getline('.'), '\#', '\\#', '')
exe "norm! mc"
exe "norm! o\<Esc>"
exe "r! " . l:com
exe "norm! mr"
exe "norm! o\<Esc>"
endfunction
Two more mappings:
exe "nnoremap " . g:leader_prime . "p :call ExecuteCurrentParagraph()\<CR>"
exe "nnoremap " . g:leader_prime . "c :call ExecuteCurrentLineWithBC()\<CR>"
and their implementations:
function! ExecuteCurrentParagraph()
let l:init = line('.')
exe "norm! {j"
let l:start = line('.')
exe "norm! }"
let l:end = line('.')
exe "norm! o\<Esc>"
exe "r! " . join(getline(l:start,l:end), ' ')
exe "norm! o\<Esc>"
endfunction
function! ExecuteCurrentLineWithBC()
let l:com = getline('.')
exe "norm! o\<Esc>"
exe "r! " . "echo 'scale=12;" . l:com . "' | bc"
exe "norm! o\<Esc>"
endfunction
As written above, I type 'sx' to execute the current line under the cursor as a shell command, and then inject the result back into the buffer where I am. 'sp' does the same, but for the entire paragraph the cursor is on; this is really convenient for things like a large sql query which is more readable written over many lines. And finally 'sc' executes the current line in the bc calculator program in the underlying shell, so you can evaluate arithmetic expressions in the buffer.