Hello everyone, In this article i will be explaning about how to create your own Boilerplate for any programming language. I will ensure that by reading article you are going to make your own Boilerplate .
Let's deep dive in to our todays article !
What's a Boilerplate Code?
While coding, a piece of code that you have to use in every program mostly in every programming language. So, instead of manually typing code in the editor, we create a code-snippet so that that part of code is easily entered without typing it manually.
Boilerplate or a code-snippet are solution provided by IDEs like VS Code, where a certain piece code can be called within a program by typing prefix names.
Let's create
I am going to create a Boilerplate for C++
Step 1: Locating C++ JSON file for adding the snippet
- Open your VS Code and click on the settings button in the bottom-left corner.
Click on User Snippets
Search for the Programming language for which you want to add boilerplate
Step 2: Adding the code to the .JSON file
You will get something like this when you open .JSON file
Remove the code below example and add this
"boilerplate": { "prefix": "boilerplate code", //The prefix can be any random name "body": [ "#include<iostream>" , "using namespace std;" , "int main()" , "{" , " $1" , " return 0;" , "}" ], "description": "Log output to console" }
- After making changes to .JSON file press Ctrl+S to save the changes.
Step 3: Nothing more just use it your program
Create a New C++ file. Now Type the prefix .
VS Code automatically suggests while you are typing the prefix name .
Press ENTER.
I hope you have found this article helpful :)
Wanna get connected! Find me on Twitter