Naveen Kumar Vunnam
Naveen Kumar Vunnam

Reputation: 159

How to add default code to every cpp file that I open in vim?

I've recently got started with competitive programming. I see a lot of competitors use vim in the competition. I want to add default code to every CPP file that I might open in vim so that I don't have to type the following routine code and a few Macros as well every time. please help me. thanks in advance.

#include <bits/stdc++.h>
using namespace std;
int main() {
             return 0;
}

Upvotes: 0

Views: 195

Answers (1)

Chelz
Chelz

Reputation: 447

One possible solution would be to create the template file and read it using the :r command in vim. The next step would be using an autocommand on *.cpp files, whenever you create a new File. see :h autocmd-groups

Upvotes: 2

Related Questions