0

I am currently using gVim to code in C++. I've recently made a skeleton file that includes imports, macros, etc., so that every time I make a new .cpp file it automatically adds the skeleton to it.

To do this, I used this line:

autocmd BufNewFile *.cpp 0r C:/Me/template.cpp

Whenever I make a new file with command prompt (vim A.cpp), a new file is created and the file contains the skeleton. However, when I create a new file using the gVim, it doesn't contain the skeleton.

In order to get the code skeleton in the file, I have to :q out of gVim then :e into the file. After :e'ing into the file, if I make changes and then :wq it says Can't write viminfo file C:/_viminfo.tmp.

Also, when I try to open the file I made with gVim through File Explorer (after getting the template on it), it appears as blank file.

How do I get gVim to automatically have the code skeleton whenever I create a new .cpp file in gVim?

3
  • 1
    What do you mean by "I have to :q out of gVim then :e into the file." – Jorengarenar Jul 11 '20 at 0:28
  • I have to exit gVim then reopen gVim. Once I reopen gVim, if I :e filename (:e into the file I just made) only then will it show the skeleton code. – ifandonlyif Jul 11 '20 at 0:31
  • Are you sure that GVim uses the same vimrc as your terminal version? Open gVim and execute :scriptnames. Do the same from your terminal Vim and compare. – Ralf Jul 11 '20 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.