Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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'm wondering if it's possible with vim to create a macro which will run only on new blank files given a certain filetype.

I'd personally like that when I create xy.tex it will automatically populate the document with my headers, etc. I realise I can run a command on opening a file by execute "echo blah" or whatever, but I'm not really sure how I'd go about executing ONLY on a new (Blank) file. Any ideas?

share|improve this question
up vote 5 down vote accepted

Use the BufNewFile autocommand event. See :h autocmd.txt for more details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.