Monday, August 6, 2012

Re: How to pass command from stdin?

On 06/08/12 23:48, Peng Yu wrote:
> vim -E -c "normal gg=G" -c "x" file
>
> The above code indent the file from command line. But the following
> one can not do so.
>
> vim -E file <<EOF
> :normal gg=G
> :x
> EOF
>
>
> It seems that I should be able to pass command from stdin. I'm not
> sure why it is not working. Could anybody let me know?
>
> Thanks,
> Peng
>

If on Linux, try (untested)

vim -S '/dev/stdin' file <<EOF
normal gg=G
x
EOF

Or you could (partly) resolve the /dev/stdin softlink, and use
'/dev/fd/0' or '/proc/self/fd/0' instead as the path to the file to be
sourced. Further resolution is not possible as you don't know Vim's PID.

On Windows, all this will probably not work, though.


Best regards,
Tony.
--
Whom computers would destroy, they must first drive mad.

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

No comments: