I use Vim for writing C++, and I have quite a few #include<>
statements, comments, etc. that I must include in each new file I create. I've added
autocmd BufNewFile *.cpp r C:\(full file path of skeleton text file)
to my vimrc, because I heard this creates a buffer with the text I need in it. How do I go about adding this text to a new file? Is there an easy way to do this from the buffer, or is there another easy way to go about doing this? I've also heard a little about template plugins. Is there a very simple one that could do this for me?
autocmd
, and creating the skeleton file?:r C:\(full file path of skeleton text file)
? Do you get any errors?:enew
won't work, but:e newfile.cpp
should work ifnewfile.cpp
didn't already exist (even if empty).:enew
wont work is because you're editing a new, unnamed buffer, and then saving it as a .cpp file.BufNewFile
only triggers if you're editing a new file with the target filename.