title: How to pipe visually selected text to a UNIX command and append output to current buffer in Vim
body: <p>Using Vim, I'm trying to pipe text selected in visual mode to a UNIX command and have the output appended to the end of the current file. For example, say we have a SQL command such as:</p>
  
  <pre><code>SELECT * FROM mytable;
  </code></pre>
  
  <p>I want to do something like the following:</p>
  
  <pre><code>&lt;ESC&gt;
  V                 " select text
  :'&lt;,'&gt;!mysql -uuser -ppass mydb
  </code></pre>
  
  <p>But instead of having the output overwrite the currently selected text, I would like to have the output appended to the end of the file. You probably see where this is going. I'm working on using Vim as a simple SQL editor. That way, I don't have to leave Vim to edit, tweak, test SQL code.</p>