11

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?

Heptite
  • 19,383
  • 5
  • 58
  • 71
chelmertz
  • 341
  • 1
  • 2
  • 12

1 Answers1

18

You can try this command:

echo c | vim - +'w f'
kev
  • 12,462
  • 13
  • 59
  • 72
  • 10
    Or if you don't want to automatically write the file to disk, but just set its name: echo "c" | vim - +"file f" – Heptite May 06 '12 at 23:07
  • Very good, thanks. @Heptite got what I really wanted, nice of you to comment. This is far my dirtiest Makefile target.. :) – chelmertz May 06 '12 at 23:25