7
3
I've read lots of threads about running shell commands from vim, lots of documentation on vim commands, .vimrc and all that, but I just can't seem to understand the "ex" language or vim mappings well enough to do what I want, so here I am asking this question. Here goes:
I have an open buffer in vim (using the latest stable MacVim on Snow Leopard, but not in gui mode) whose contents I will later feed into a command-line tool that will process it and give me some output. What I want is to be able to:
- Press a key (or key combination, or issue a vi command)
- Run my command-line utility with the contents of my current buffer (which might not be saved to the file) piped into it
- Capture its output and show it in vim, preferrably in a new split window (like :help does)
So, in summary: I can run
$ cat ~/myinput.txt | myScript > output.txt
But I want to do something like that inside of vim, putting the output in a new split window if possible.
UPDATE:
Of course, just after posting, I found some more information on the subject. I now know that I can do this inside vim:
:%! myScript
And it will put the output of myScript (with the buffer contents piped to it) into my current buffer, replacing whatever I have in it right now.
So is there a way to put these contents into a new, split window, buffer? Thanks!
This worked, thanks! I'll see about the parameters later, lots to learn about scripting vim. Thank you for your help. – malvim – 2011-04-06T22:38:46.323