from Hacker News

Show HN: I wrote a tool that generate VS Code code snippets

by djyde on 12/24/20, 4:17 PM with 1 comments

  • by djyde on 12/24/20, 4:17 PM

    https://github.com/djyde/snp

    When I found myself repeat typing some codes over and over again, I started to use code snippet help me generate these codes. It saved me so much time.

    But VS Code snippet syntax [1] is hard to write and maintain. So I find some code snippet manager applications, but they are all just help me copy and paste. However, the IDE native code snippet can do a lot more than just generate codes.

    So I wrote a command line tool that generates the VS Code snippet file. It looks up all the `.snp` files (which is a file contains the snippet code) in current working directory and generate the code-snippets file to VS Code snippets folder. You don't have to do anything in VS Code and it just work.

    You could see how do I use this tool to manage my snippets: https://github.com/djyde/snippets

    (P.S. This is my first time writing Go code. I first write this tool in Node.js in 30 mins. Then I want to make it a single executable file. So I rewrite it in Go. It cost me 2 hours :P)

    - [1] https://code.visualstudio.com/docs/editor/userdefinedsnippet...