Read from stdin to new, named, file in vim

4

2

I'd like to start vim on a non existing file, named f, with the content c. Both f and c are arbitrary and I'd like to not have to put anything in the vim config to fill new buffers with c.

Basically, I would like to combine

$ echo c | vim -

with

$ vim f

Is there a flag to vim which lets me achieve this?

chelmertz

Posted 2012-05-06T22:57:04.013

Reputation: 231

Answers

9

You can try this command:

echo c | vim - +'w f'

kev

Posted 2012-05-06T22:57:04.013

Reputation: 9 972

6Or if you don't want to automatically write the file to disk, but just set its name: echo "c" | vim - +"file f" – Heptite – 2012-05-06T23:07:09.740

Very good, thanks. @Heptite got what I really wanted, nice of you to comment. This is far my dirtiest Makefile target.. :) – chelmertz – 2012-05-06T23:25:11.607