Easily create VS Code Snippet by copy-pasting into the command line, or loading the desired text from a text file.
See official docs, to make your snippet executable.
$ python3 snippet_make.py --help
usage: snippet_make.py [-h] [--text_file TEXT_FILE] [--paste] --title TITLE --prefix PREFIX [--desc DESC]
Make VS Code Snippet from text file or clipboard
options:
-h, --help show this help message and exit
--text_file TEXT_FILE
Load code from text file
--paste Paste code directly into console
--title TITLE Name of snippet in JSON
--prefix PREFIX Shortcut to call snippet
--desc DESC Descriptive description of your snippet (optional)
Example of text to create snippet from
#!/usr/bin/env python3
Input:
$ python3 snippet_make.py --text_file "test/test_py_shebang.txt" --title "Python shebang" --prefix "pyshebang"
Output:
"Python shebang": {
"prefix": "pyshebang",
"body": [
"#!/usr/bin/env python3"
],
"description": ""
}
$ python3 snippet_make.py --paste --title "Python shebang" --prefix "pyshebang"
Credit to @xiaket et al. on this StackOverflow post, for implementation of multi-line text input in Python. 🙏