When I create a .tex file using vim I get a nice template from having
autocmd BufNewFile *.tex 0r $HOME/.vim/templates/skeleton.tex
in my .vimrc. I also have a makefile-template in my home directory, but this one I have to manually copy to where the .tex file is. In a Linux environment, how can I auto-copy or auto-generate the makefile at the same time as I create a .tex file?
The portable answer would not use
cp(which may overwrite a preexisting makefile) but the vim functions readfile() and writefile().To trigger it, the best thing would be to define and execute a function that loads the first skeleton, and creates the Makefile on the fly: