Create Custom Snippet In Visual Studio Code
don’t you found a snippet suitable for you, don’t worry you can create a custom snippet. Let’s we are creating a snippet step by step.
1- We Need To Snippet Generator
We need to snippet generator, the following website is a simple Snippet generator just open up and follow to steps.
2- Select Language And Editor
Secondly, select programming language and code editor after that we are ready to create snippets.
3- Write Code
Now, we have to write code for snippets. For example, we gonna create a loop statement in Java.
Above, we wrote a loop statement and we enter description and keyword. did you see, I use $ because when I call this statement I gonna edit this value.
Create Snippet File In Visual Studio Code
Press Ctrl + Shift + P, and write Configure User Snippet after that, select programming language and that’s it now we have a snippet file. Clear all and open curly brackets paste snippet code from Snippet-Generator.
Above, I showed you how to create a new snippet file, and update this file.
TEST TIME!
Let’s use this snippet in a java file.
Yes! The loop statement is working. You can add more statements in your snippet.