When creating a new file with vim, I would like to automatically add some skeleton code.
For example, when creating a new xml file, I would like to add the first lin
Sorry for the lateness, but I feel the way I do it might be useful to some. It uses the file's filetype, making it shorter and more dynamic than more conventional methods. It was tested only on Vim 7.3.
if has("win32") || has ('win64')
let $VIMHOME = $HOME."/vimfiles/"
else
let $VIMHOME = $HOME."/.vim/"
endif
" add templates in templates/ using filetype as file name
au BufNewFile * :silent! exec ":0r ".$VIMHOME."templates/".&ft