Sylvain Leroux wrote:
> I finally decided to post here as I can't find the solution by myself.
> I'm looking for a way to use some range of the buffer as input to an
> external command, and *inserting* the command output into the buffer.
>
> I'm aware of the `!` command but it doesn't match my need as it
> *replaces* the original data. I want to keep them. The `r!` command
> doesn't match either as (AFAIK) you cannot send data from the buffer
> as input to the command.
>
> To make things more clear here is a typical use case
> (I use the `wc` command for illustration purpose only):
>
> == Original buffer ==============
> Mar 2016 1.78%
> Apr 2016 1.65%
> May 2016 1.79%
> Jun 2016 2.02%
> Jul 2016 2.33%
>
> Linux Market Share on Desktop
> =================================
>
> == Command (??? denotes the mystery command I'm looking for)
> :1,/^$/-1 ??? wc -l
>
> == Expected buffer ==============
> 5
> Mar 2016 1.78%
> Apr 2016 1.65%
> May 2016 1.79%
> Jun 2016 2.02%
> Jul 2016 2.33%
> Mar 2016 1.78%
> Apr 2016 1.65%
> May 2016 1.79%
> Jun 2016 2.02%
> Jul 2016 2.33%
>
> Linux Market Share on Desktop
> =================================
>
>
> Any idea on how to achieve that? If there isn't any Vim command to do
> that directly, maybe using a register? As you can see, any help or
> pointer to the right direction would be greatly appreciated.
I don't think it can be done with one command. Simplest seems to be to
copy the text and then filter it.
(visually select the text)
YP
gv
:!filter-command
Would not be a bad idea to have an Ex command for this. Not sure what
to call it, :feed perhaps? :writeread ?
--
An SQL statement walks into a bar. He approaches two tables
and says, "Mind if I join you?"
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thursday, February 9, 2017
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment