Make your Own VsCode Snippets

Make your Own VsCode Snippets

Β·

2 min read

Make your Own VsCode Snippets

Snippets are very useful for quickly creating code, but do you know it's more AWESOME to make one?

Make your own snippets in VsCode

1. Open VsCode and type

Press Ctrl + Shift + P to Open Command Palette in VsCode.

Image description

1. type Configure User Snippets

πŸ’₯ Enter

1. type Select the language you want to create snippets for
  • java
  • javascript
  • python
  • css .... Let's Enter Javascript. Image description
    {
      // ↓ this is name of snippet
      "Print to console": {
          // ↓ this is prefix the command will be typed to use it.
           "prefix": "log",
          //  ↓ this is the snippet itself, body of the snippet
           "body": [
              //  $1 is the placeholder for the first argument, $number defines tabindex for the snippet.
               "console.log('$1');",
               "$2"
           ],
          //  ↓ this is the description of the snippet.
           "description": "Log output to console"
       }
    }
    
1. type Save the snippet/ Close the file.
2. Make a file index.js
3. use the prefix to type the snippet.
4. type log and hit enter.

you can also add more functionality like filename, foldername, cursor position, to your snippets, as a adding variables to your snippets

Read more variables in snippets from VsCode snippets docs.

Share which snippets you are gonna create with this

Thanks for reading. Share your snippets with everyone. comment about topics you like.

🀝🏾Connect me on: Twitter: πŸ•ŠοΈ@Abhayprajapati_ Github: 🐧@theabhayprajapati Linkedin: πŸ“Œ@abhayprajaapati Youtube: πŸ“Ί@Abhayprajapati

Did you find this article valuable?

Support @Abhay's Blog by becoming a sponsor. Any amount is appreciated!

Β