- ... Iirc, you don t. ... A very crude hack. With a stdout.vim file reading silent exec w . tempname() silent !type % silent !del % q! you could invoke vimMessage 1 of 4 , Apr 1, 2002View SourceThus wrote Benji Fisher (benji@...) on :
> Can vim be used as a filter, like sed? For example,Iirc, you don't.
> % ls | vim - --other-options
> I think the - option makes vim read a buffer from stdin, but how do we get it
> to write to stdout?
> I especially want this to work on Windows, where sed mayA very crude hack. With a stdout.vim file reading
> not be available.
silent exec 'w ' . tempname()
silent !type %
silent !del %
you could invoke vim as
% ... | vim -c "so .../stdout.vim" -
Not sure how "-s script" works with file in dos format, so I did not
like to use it here. Alternatively, use ":runtime dosutils/stdout.vim".
Not sure either how the type and del commands work from within vim
under windows (does it still pop up windows with dos prompts?).
Also, you would have to get rid off the leading "Vim: Reading from
stdin..." and trailing blank line.
Peppe [tested the equivalent on a unix box]
"Before you criticize someone, walk
Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
c928400@... (o o) he gets angry, he'll be a mile away
----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
- ... Hash: SHA1 ... I think you should think over what you want to do. Since the 70 s when the first vi came out for some UNIX Computer it was thought as aMessage 2 of 4 , Apr 1, 2002View Source-----BEGIN PGP SIGNED MESSAGE-----
On Monday, 1. April 2002 21:12, Benji Fisher wrote:
> Can vim be used as a filter, like sed? For example,
> % ls | vim - --other-options
> I think the - option makes vim read a buffer from stdin, but how do we get
> it to write to stdout? I especially want this to work on Windows, where
> sed may not be available.
> Background: If I run :make then the compiler output is saved to an
> error file. AFAIK, I do not have a chance to clean up that error file,
> except by adding a filter to 'makeprg'. If I am running vim on Windows, I
> would like to use vim itself as the filter program.
> I might also want to do the same for 'equalprg'.
> --Benji Fisher
I think you should think over what you want to do. Since the 70's when the
first vi came out for some UNIX Computer it was thought as a "VISUAL" editor.
That's where the name comes from. Now you want to make it invisible again.
First, if you like System V,X/Open or Posix, all our nice UNIX standards, you
should try to install a cygwin or something similar for your Windows. Then
you can work with most of the well known commands like ed/sed ...
Most solutions you can find with other concepts might be much more flexible
and useful. But if you don't use a "|vim -" to read from stdin you should
also be able to call vim commands through stdin:
# This example only works for unix of course.
cat cmd-script| vim bla bla &> /dev/null
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----