Thursday, June 28, 2012

Re: vim: use external program, but direct output to a new vsplitted buffer

On 2012-06-28, ping wrote:

> 2) :'<,>'w !ext-prog
> I found this syntax is interesting.
> it take seleted text as input, but just print the output to the
> screen, without overiding the selected text. which seems good.
>
> so using another tip I learned from a previous thread, how about this:
>
> "redirect output to reg z
> :redir @z
> "take seleted text as input, output to screen
> :'<,'> !asciidoc ...
> "end redirection
> :redir END
> "open a vsplit win
> :vsp
> "paste content of reg z
> "zp
>
> surprisingly I got nothing here.

:redir redirects the output of Vim commands, not shell commands.

> currently I'm just using:
> :'<,'>!ext-prog
> yank the output (which overide my original texts as input)
> u to recover my text back
> open another window and paste

If I were doing this, I would do something like this:

:'<,'>w !ext-prog > /tmp/mytmpfile
:new
:r /tmp/mytmpfile
:!rm /tmp/mytmpfile

or

:'<,'>w !ext-prog > /tmp/mytmpfile
:split /tmp/mytmpfile

I'll leave the generation of the temporary file name to you. Some
people are really paranoid about it. If you're going to have more
than one such temporary file open at a time, use tempname().

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: