Thursday, June 28, 2012

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

thanks Ben, for the solutions.
looks like the default behavior is , if you selected a range of text as
the input, then the output from external prog will overide the input
texts...

1) to summarize as a learning excercise
http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
this looks good when no need use range of text as input

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.

3) yes asciidoc has its way to define an output filename, but my again
that's not what I want (I want the def a similar behavior like :TOhtml)

but it's not big deal. either way I can done my work, just wonder what's
the best options here.

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

regards
ping


On 06/28/2012 11:20 AM, Ben Fritz wrote:

>
> I first thought of this:
>
> http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window
>
> But it looks like it won't work for your purposes, because you want to use lines in the current buffer as input to the external command.
>
> You could probably use :'<,'>w !asciidoc ...
>
> But then you'll need to put that output into a new buffer somehow.
>
> Probably you can :'<,'>w !asciidoc ... > somefile.html
>
> and then load somefile.html into a new buffer.
>
> Or maybe, asciidoc has an option to write to a file?
>
> Anyway, the relevant help is :help :w_c
>

--
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:

Post a Comment