Saturday, February 11, 2017

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

Tim Chase wrote:

> On 2017-02-09 16:06, Bram Moolenaar wrote:
> > 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 ?
>
> With three input parameters (source range, destination location, and
> command to execute), I'm unaware of anything that currently does
> this.

The :move and :copy command do have a range and a destination address.
We should follow that syntax, and put a command at the end.

> Fortunately, copying should also set the '[ and '] marks, so
> something similar to the above would work even in builds without
> visual mode:
>
> :{range}t{destination}
> :'[,']!{filter-command}
>
> If it's limited to putting input at a given line, I'd want/expect the
> full power of ex range/line specifiers, allowing for complex offsets
> like
>
> :{range}cmd?^TABLE OF CONTENTS$?+1 {filter-command}
>
> (such as :t and :m allow for targets)
>
> That said, it's not that hard to use the pair of commands above (or
> map it or make a :command), so I don't see a great need for a new
> built-in to do the same.

Perhaps this will work:
:{range}copy {address} !cmd

It's like making a copy, but filtering the text.

--
Clothes make the man. Naked people have little or no influence on society.
-- Mark Twain (Samuel Clemens) (1835-1910)

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

No comments:

Post a Comment