how to: vim -o STDIN somefile.txt

35 views
Skip to first unread message

her

unread,
Oct 3, 2012, 8:20:37 PM10/3/12
to v...@vim.org
how can i do this:

vim -o STDIN somefile.txt

what i want is something like this:

$ vim -o "some text from stdin that i typed" somefilename.txt

and vim would open horizontally splitted as in:

some text from stdin that i typed
-------------------------
stuff from somefilename.txt



--
View this message in context: http://vim.1045645.n5.nabble.com/how-to-vim-o-STDIN-somefile-txt-tp5711133.html
Sent from the Vim - General mailing list archive at Nabble.com.

Jürgen Krämer

unread,
Oct 4, 2012, 11:00:13 AM10/4/12
to vim...@googlegroups.com

Hi,

her wrote:
> how can i do this:
>
> vim -o STDIN somefile.txt
>
> what i want is something like this:
>
> $ vim -o "some text from stdin that i typed" somefilename.txt
>
> and vim would open horizontally splitted as in:
>
> some text from stdin that i typed
> -------------------------
> stuff from somefilename.txt

$ echo "some text from stdin that i typed" | vim - -c "sp somefilename.txt"

or

$ cat | vim - -c "sp somefilename.txt"

Regards,
J�rgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

Tim Chase

unread,
Oct 4, 2012, 11:02:36 AM10/4/12
to v...@vim.org, her
On 10/03/12 19:20, her wrote:
> how can i do this:
>
> vim -o STDIN somefile.txt
>
> what i want is something like this:
>
> $ vim -o "some text from stdin that i typed" somefilename.txt
>
> and vim would open horizontally splitted as in:
>
> some text from stdin that i typed
> -------------------------
> stuff from somefilename.txt

I was somewhat surprised that Vim doesn't seem[1] to support
multiple filenames of which one is stdin without a workaround. I'd
*expect* to be able to do something like

echo "some text from stdin" | vim -o - somefile.txt

however that gives me a

Too many edit arguments: "somefile.txt"

You can work around it with this convoluted invocation:

echo "some text from stdin" | vim -c "sp somefile.txt" -

(or "below sp somefile.txt" depending on the order you want)

-tim

[1]
my usual caveat that this is 7.2.445 on Debian Stable, and 7.3.x is
the latest and greatest; so this may no longer be the case.


Ben Fritz

unread,
Oct 4, 2012, 10:50:02 PM10/4/12
to vim...@googlegroups.com, v...@vim.org, her
On Thursday, October 4, 2012 10:01:54 AM UTC-5, Tim Chase wrote:
>
>
> You can work around it with this convoluted invocation:
>
>
>
> echo "some text from stdin" | vim -c "sp somefile.txt" -
>
>

Or even worse for multiple files:

echo "some text from stdin" | vim -c new -c "args *.txt" -c sball -
Reply all
Reply to author
Forward
0 new messages