Vi/Vim: How to pipe visually selected text to a UNIX command and append output to current file

Posted by drsnyder on Stack Overflow See other posts from Stack Overflow or by drsnyder
Published on 2008-10-23T15:45:30Z Indexed on 2010/04/04 19:03 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

Using Vim, I'm trying to pipe visually selected text 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:

SELECT * FROM mytable;

I want to do something like the following:

V # select text :'<,'>!mysql -uuser -ppass mydb

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.

Thanks!

© Stack Overflow or respective owner

Related posts about vi

Related posts about vim