Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -


$ vim f

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

share|improve this question
up vote 4 down vote accepted

You can try this command:

echo c | vim - +'w f'
share|improve this answer
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 6 '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 6 '12 at 23:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .