Skip to content

prince-ravi-leow/snippet-make

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snippet_make.py

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.

Usage

$ 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)

Examples

Example of text to create snippet from

#!/usr/bin/env python3

From text file (--text_file "file.txt")

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": ""
}

From clipboard (--paste)

$ python3 snippet_make.py --paste --title "Python shebang" --prefix "pyshebang"

paste_animation

Acknowledgements

Credit to @xiaket et al. on this StackOverflow post, for implementation of multi-line text input in Python. 🙏

Releases

No releases published

Packages

No packages published

Languages