Moving fast with the core Vim motions
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.<p><pre><code>  &quot;execute the contents of the current line =&gt; sx
    exe &quot;nnoremap &quot; . g:leader_prime . &quot;x :call ExecuteCurrentLine()\&lt;CR&gt;&quot;
</code></pre>
Here leader_prime is just a second leader key I use: &#x27;s&#x27;, but you could map the command however you like. ExecuteCurrentLine() is implemented as:<p><pre><code>  function! ExecuteCurrentLine()
    let l:com = substitute(getline(&#x27;.&#x27;), &#x27;\#&#x27;, &#x27;\\#&#x27;, &#x27;&#x27;)
    exe &quot;norm! mc&quot;
    exe &quot;norm! o\&lt;Esc&gt;&quot;
    exe &quot;r! &quot; . l:com
    exe &quot;norm! mr&quot;
    exe &quot;norm! o\&lt;Esc&gt;&quot;
  endfunction
</code></pre>
Two more mappings:<p><pre><code>  exe &quot;nnoremap &quot; . g:leader_prime . &quot;p :call ExecuteCurrentParagraph()\&lt;CR&gt;&quot;
  exe &quot;nnoremap &quot; . g:leader_prime . &quot;c :call ExecuteCurrentLineWithBC()\&lt;CR&gt;&quot;
</code></pre>
and their implementations:<p><pre><code>  function! ExecuteCurrentParagraph()
    let l:init = line(&#x27;.&#x27;)
    exe &quot;norm! {j&quot;
    let l:start = line(&#x27;.&#x27;)
    exe &quot;norm! }&quot;
    let l:end = line(&#x27;.&#x27;)
    exe &quot;norm! o\&lt;Esc&gt;&quot;
    exe &quot;r! &quot; . join(getline(l:start,l:end), &#x27; &#x27;)
    exe &quot;norm! o\&lt;Esc&gt;&quot;
  endfunction

  function! ExecuteCurrentLineWithBC()
    let l:com = getline(&#x27;.&#x27;)
    exe &quot;norm! o\&lt;Esc&gt;&quot;
    exe &quot;r! &quot; . &quot;echo &#x27;scale=12;&quot; . l:com . &quot;&#x27; | bc&quot;
    exe &quot;norm! o\&lt;Esc&gt;&quot;
  endfunction
</code></pre>
As written above, I type &#x27;sx&#x27; to execute the current line under the cursor as a shell command, and then inject the result back into the buffer where I am. &#x27;sp&#x27; 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 &#x27;sc&#x27; executes the current line in the bc calculator program in the underlying shell, so you can evaluate arithmetic expressions in the buffer.