Saturday, December 28, 2013

Re: Function to pipe data through external command ?

On 2013-12-28, Andre Majorel wrote:

> On 2013-12-27 11:15 -0800, Gary Johnson wrote:
>
> > For finer-grained selection, try Chip Campbell's vis.vim plugin:
> > http://vim.sourceforge.net/scripts/script.php?script_id=1195
> >
> > It allows you to visually-select a portion of a line (or lines) and
> > pass just that portion to a Vim command, including an external
> > command.
>
> Oh boy. Why is it that when I ask how to do something in Vim,
> half the time, the answers are along the lines of "it's
> somewhere in that thousand line long script" ? :-D

I don't understand. I never meant to suggest that you try to
extract some code from that script or understand its internal
workings; I meant that you should use it as-is.

For example, with vis.vim installed and given the line

The quick brown fox jumped over the lazy dogs.

move the cursor to the f in fox and type

v2e:B !rev

and Enter. The result will be the line below, where the string
"fox jumped" was filtered by the external program rev and replaced
by the reversed string "depmuj xof ". (I don't know where the
extra two spaces came from, but that's not the point here.)

The quick brown depmuj xof over the lazy dogs.

> Thanks for your replies, though.
>
> I'm not fluent enough in Vim script to be sure but it seems that
> neither script provides a way of piping besides the native
> ":execute {range}!".

That _is_ what vis.vim provides: a way to execute any Vim ex
command, including piping, on a selected region of text.

Am I missing something?

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

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

No comments: