('|') in perldo

1 view
Skip to first unread message

Edward Peschko

unread,
Nov 18, 2008, 9:13:57 PM11/18/08
to vim...@googlegroups.com
also -

how do you represent an or ('|') in a perldo command? Right now, it
gives a syntax error; it looks like it short circuits the line rather
than represents an or in a regular expression..

Ed

Tony Mechelynck

unread,
Nov 18, 2008, 11:37:10 PM11/18/08
to vim...@googlegroups.com

- Your Vim version is compiled with +perl, of course? (Check the output
of ":version".)
- Which Perl command are you trying to execute for each line in the
range (or, by default, in the file)?
- What is the text of the error you get?

Since :perldo is listed at ":help :bar", it would seem that the
":perldo" command sees the bar as part of its argument.


Best regards,
Tony.
--
Peter's Law of Substitution:
Look after the molehills, and the mountains will look after
themselves.

Chris Suter

unread,
Nov 18, 2008, 11:49:56 PM11/18/08
to vim...@googlegroups.com
i've found the "|" to act funny in ex commands at times (e.g. :!cat /var/log/messages | grep blah) and find that escaping ("\|") does the trick.

not sure what the actual presumed underlying meaning of "|" is, but :help map_bar indicates that the "|" is used in separating map commands...

anyway, try escaping it?
--
Christopher Suter

Tony Mechelynck

unread,
Nov 19, 2008, 12:01:20 AM11/19/08
to vim...@googlegroups.com
On 19/11/08 05:49, Chris Suter wrote:
> i've found the "|" to act funny in ex commands at times (e.g. :!cat
> /var/log/messages | grep blah) and find that escaping ("\|") does the trick.
>
> not sure what the actual presumed underlying meaning of "|" is, but
> :help map_bar indicates that the "|" is used in separating map commands...
>
> anyway, try escaping it?

In external commands, | separates two processes to be run in such way
that the sysout of the first (cat) is fed on sysin to the second (grep).
(In this case you could, more simply, do "grep blah <
/var/log/messages"). Since Vim uses bash (or cmd.exe or whatever) to run
the external command, the bar must be escaped on the bash command-line.
In the :perl and :perldo commands it might be different.

>
> On Tue, Nov 18, 2008 at 11:37 PM, Tony Mechelynck
> <antoine.m...@gmail.com <mailto:antoine.m...@gmail.com>> wrote:
>
>
> On 19/11/08 03:13, Edward Peschko wrote:
> > also -
> >
> > how do you represent an or ('|') in a perldo command? Right now, it
> > gives a syntax error; it looks like it short circuits the line rather
> > than represents an or in a regular expression..
> >
> > Ed
>
> - Your Vim version is compiled with +perl, of course? (Check the output
> of ":version".)
> - Which Perl command are you trying to execute for each line in the
> range (or, by default, in the file)?
> - What is the text of the error you get?
>
> Since :perldo is listed at ":help :bar", it would seem that the
> ":perldo" command sees the bar as part of its argument.
>
>
> Best regards,
> Tony.
--

"My life is a soap opera, but who has the rights?"
-- MadameX

Matt Wozniski

unread,
Nov 19, 2008, 8:27:32 AM11/19/08
to vim...@googlegroups.com
On Wed, Nov 19, 2008 at 12:01 AM, Tony Mechelynck wrote:
>
> In external commands, | separates two processes to be run in such way
> that the sysout of the first (cat) is fed on sysin to the second (grep).
> (In this case you could, more simply, do "grep blah <
> /var/log/messages"). Since Vim uses bash (or cmd.exe or whatever) to run
> the external command, the bar must be escaped on the bash command-line.
> In the :perl and :perldo commands it might be different.

You can even go one character shorter by leaving out the redirection.
grep blah /var/log/messages

~Matt

Reply all
Reply to author
Forward
0 new messages