Take the 2-minute tour ×

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
add comment

1 Answer

up vote 5 down vote accepted

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

share|improve this answer
add comment

Your Answer


