← All extensions

Python Snippets

v0.1.3 · by Carlos Tosta · added 3 November 2026

Python snippets for Zed IDE. A collection of python snippets to improve your development speed.

Snippets

How to install

With Forge Super installed, the button above opens the app on this extension, where you press Install. Nothing is installed until you do.

You can also open the Extensions panel in the app and search for Python Snippets. The extension's id is python-snippets.

Don't have Forge Super yet? Download it here.

README

From the extension's repository, written by its authors and not by Mentenaz. See the source.

Python Snippets for Zed IDE

A collection of Python snippets for the Zed IDE to improve your development speed and productivity.

Features

This extension provides a comprehensive set of snippets for Python development, including:

  • Package and import declarations
  • Control structures (if, for, while, try/except)
  • Function and method declarations
  • Modern Python features (f-strings, type hints, dataclasses)
  • Framework-specific snippets (FastAPI, Pydantic, Typer)
  • Database ORM snippets (SQLAlchemy)
  • Testing helpers (unittest, pytest)
  • And much more!

Installation

Method 1

  1. Go to Extensions menu in Zed IDE
  2. Search for "python-snippets"
  3. Click "Install"

Method 2

  1. Clone this repo:
git clone https://github.com/jctosta/python-zed-snippets.git
  1. Go to Extensions menu in Zed IDE
  2. Click "Install Dev Extension"
  3. Select the folder you cloned

Usage

To make snippets appear at the top of the completion list in Zed, add this setting to your Zed settings file:

{
    "snippet_sort_order": "top"
}

Start typing the snippet prefix (e.g., def) in a Python file and press Tab to expand the snippet.

Available Snippets

PrefixDescription
imImport module
ifmImport from module
mainif __name__ == "__main__" entrypoint
defFunction definition
classClass definition
propProperty (getter)
methMethod definition
forFor loop
whileWhile loop
ifIf statement
ifelseIf-else statement
elifElif block
tryTry-except block
tryfTry-except-finally block
withWith context manager
ctxContext manager class
decoDecorator function
lambdaLambda expression
lcList comprehension
printPrint statement
fsF-string
logiLogging info message
logdLogging debug message
FastAPI
fastapi-appFastAPI minimal app
fastapi-routeFastAPI route handler
fastapi-depFastAPI dependency function
Pydantic
pydbasePydantic BaseModel class
pydvalPydantic validator
Typer
typer-appTyper CLI application setup
SQLAlchemy
sa-baseSQLAlchemy Base import
sa-modelSQLAlchemy Model
sa-sessionSQLAlchemy session setup
unittest
utUnittest TestCase
utmainUnittest main entrypoint
pytest
ptPytest test function
ptpPytest parametrize test
ptfixPytest fixture
pttablePytest table-driven test (parametrize)
Asyncio
adefAsync coroutine definition
atgAsync TaskGroup context manager definition
amainMain entrypoint with asyncio.run function
Misc
dcPython dataclass
hintfFunction with type hints
docFunction docstring template

Examples

Function definition

Type def and press Tab:

def func(args):
    # Your code here

If statement

Type if and press Tab:

if condition:
    # Your code here

Class with property and method

Type class, then prop, and meth inside the class, and press Tab each time:

class MyClass(object):
    def __init__(self, value):
        self._value = value

    @property
    def value(self):
        return self._value

    def my_method(self, arg):
        # Your code here

FastAPI minimal app

Type fastapi-app and press Tab:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

Pytest test function

Type pt and press Tab:

def test_func():
    # Your test code here

Dataclass

Type dc and press Tab:

from dataclasses import dataclass

@dataclass
class Name:
    field: type

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Author

Carlos Tosta - jctosta86@gmail.com

Acknowledgments

This extension is inspired by and based on the excellent Go Snippets for Zed IDE created by Ayberk Gezer. Many of the snippet ideas, naming conventions, and file structure for this Python extension are derived from that project.

Special thanks to Ayberk Gezer for providing a solid foundation and reference implementation.

Repository

https://github.com/jctosta/python-zed-snippets