I have a file template which is rendered with replacing some stubs when new file created:
augroup templates autocmd! autocmd BufNewFile *.java $r ~/.vim/templates/skeleton.java|call s:SetupJavaClass() fun! s:SetupJavaClass() exe "%s/__CLASS_NAME__/" . expand('%:t:r') endfun augroup END
it's working fine, but only if I create new file with new buffer, e.g.
vim Foo.java works, but when I create new file from NerdTree, new file is opening in current buffer and my templates and vim doesn't call my autocommands. How can I fix it? Is it possible to create autocommand to be executed on every new file, doesn't matter it was opened in new buffer or not, or maybe I should use ftplugin for that?