VS Code Snippet Generator
Create custom VS Code snippets with tabstops, placeholders, and variable syntax for any language.
Use $1, $2 for tabstops; ${1:placeholder} for default values; $0 for final cursor
{
"My Snippet": {
"prefix": "mysnippet",
"body": [
"console.log($1);"
],
"description": ""
}
}Preguntas Frecuentes
Implementación de Código
import json
def generate_vscode_snippet(
name: str,
prefix: str,
body: list[str],
description: str = "",
scope: str = ""
) -> dict:
snippet = {
name: {
"prefix": prefix,
"body": body,
"description": description,
}
}
if scope:
snippet[name]["scope"] = scope
return snippet
# Example: Python class snippet
snippet = generate_vscode_snippet(
name="Python Class",
prefix="cls",
body=[
"class ${1:ClassName}:",
" def __init__(self${2:, args}):",
" ${3:pass}",
"",
" def __repr__(self):",
" return f"${1:ClassName}(${4:fields})"",
],
description="Create a Python class with __init__ and __repr__",
scope="python"
)
print(json.dumps(snippet, indent=4))Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.