title: How can I execute the current line as Vim EX commands?
body: <p>Say I'm editing my <code>_vimrc</code> file and I've just added a couple of lines, for instance a new key mapping. I don't want to reload the <em>whole</em> file (<code>:so %</code>) since that will reset a lot of temporary stuff I'm experimenting with. I just want to run the two lines that I'm currently working on.</p>
  
  <p>I'm having no luck trying to copy/paste the lines into the command buffer, since I can't use the put command in there. Is there any way I could run the current line (or current selection) as EX commands?</p>
  
  <hr>
  
  <p><strong>Summary:</strong></p>
  
  <p>After <a href="https://stackoverflow.com/users/1947008/anton-kovalenko">Anton Kovalenko</a>'s answer and <a href="https://stackoverflow.com/users/438329/peter-rincker">Peter Rincker</a>'s comment I ended up with these key maps, which either executes the current line, or the current selected lines if in visual mode:</p>
  
  <pre><code>" Execute current line or current selection as Vim EX commands.
  nnoremap &lt;F2&gt; :exe getline(".")&lt;CR&gt;
  vnoremap &lt;F2&gt; :&lt;C-w&gt;exe join(getline("'&lt;","'&gt;"),'&lt;Bar&gt;')&lt;CR&gt;
  </code></pre>