Skip to content

Installation

Requirements

From PyPI

pip install behave-format
pipx install behave-format
uv pip install behave-format

From source

git clone https://github.com/MathiasPaulenko/behave-format.git
cd behave-format
pip install -e ".[dev]"

Pre-commit hook

Add behave-format to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/MathiasPaulenko/behave-format
    rev: v1.0.1
    hooks:
      - id: behave-format

Then install the hook:

pre-commit install
pre-commit run --all-files

Verify installation

behave-format --version
# behave-format 1.0.1
behave-format --help
# Usage: behave-format [OPTIONS] PATH...

Editor integration

VS Code

Add to .vscode/settings.json:

{
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Or use a task in .vscode/tasks.json:

{
  "label": "Format Feature Files",
  "command": "behave-format",
  "args": ["${workspaceFolder}/features/"],
  "type": "shell"
}

Vim / Neovim

Use --stdin mode with your formatter of choice:

autocmd BufWritePre *.feature :%!behave-format --stdin

Any editor

behave-format supports --stdin mode, which reads from stdin and writes formatted output to stdout. This works with any editor that supports external formatters:

behave-format --stdin < my-feature.feature