# turbo-python snippets. # # Each [[snippet]] becomes one line of the Snippets menu. Snippets sharing a # group appear together in a submenu of that name; one with no group goes into # %s. A snippet is inserted at the cursor, and every line after the # first is indented to match the line you inserted it on. # # languages restricts a snippet to files of those kinds, by the names the # editor uses: python, toml, yaml, markdown, javascript, html, xml, dockerfile, # bash. Leave it out and the snippet is offered everywhere. # # Bodies are indented with four spaces, never a tab: that is what PEP 8 asks # for, and a tab inserted into a file indented with spaces is an indentation # error rather than a formatting quibble. # # Your own snippets, shared across every project, go in: # %s [[snippet]] name = "main guard" group = "Python" languages = ["python"] body = """ def main() -> None: ... if __name__ == "__main__": main()""" [[snippet]] name = "class" group = "Python" languages = ["python"] body = """ class Thing: def __init__(self, name: str) -> None: self.name = name""" [[snippet]] name = "match" group = "Python" languages = ["python"] body = """ match value: case 0: ... case _: ...""" [[snippet]] name = "try / except" group = "Python" languages = ["python"] body = """ try: ... except ValueError as error: raise SystemExit(error) from error""" [[snippet]] name = "dataclass" group = "Python" languages = ["python"] body = """ @dataclass(frozen=True) class Thing: name: str count: int = 0""" [[snippet]] name = "test" group = "Python" languages = ["python"] body = """ def test_it_works() -> None: assert 1 + 1 == 2""" [[snippet]] group = "General" name = "Hello" body = "Hello!!!" [[snippet]] group = "Markdown" name = "Image" languages = ["markdown"] body = "![img](./pictures)"