In CodeBlocks it is possible to set up a code that will open each time you create a new file. Kind of a code template or skeleton.
How can I set up a default code to open in Visual Studio Code C++ so I don't have to write it each time I create a new file? I mean, instead of creating a blank file, I need it to show the following code:
#include <iostream>
using namespace std;
int main(){
}
Go to this link.
Type/Paste the default code you want to use the snippet for. Enter the trigger and description.
Copy the generated snippet onto clipboard.
Head to VSC. Press ctr + shift + p
.Type configure user snippets
.
5.Select your desired language(C++ in your case).
Replace the comments with the snippet in your clipboard.
Save and exit. Now try to type the trigger text. You will see the snippet ready!
(snippet code is in JSON)
// Write this code in the cpp.json file
{
"cpp snippets":
{
"prefix" : "basic",
"body" : [
"#include<iostream>",
"using namespace std;",
"int main()",
"{",
" return 0;",
"}"
],
"description" : "c++ basic"
}
}
to create custom snippet code, check this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With