Wednesday, February 8, 2017

Filter-like command -- but to insert instead of replacing

Hello Vim users,

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%

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.

Best regards,
- Sylvain

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

No comments:

Post a Comment