snapper — Semantic Line Breaks for Academic Writing
Author: TurtleTech ehf
Description: A fast, format-aware semantic line break formatter for Org-mode, LaTeX, Markdown, and plaintext. Produces clean git diffs for collaborative academic writing.
Keywords: semantic line breaks, formatter, LaTeX, Org-mode, Markdown, git diff, academic writing, sentence splitting, pre-commit

# Snap your prose into
clean, diff-friendly lines

A fast, format-aware semantic line break formatter for academic papers and collaborative writing.

View on GitHub
Documentation

See it in action

## One sentence, one line

Traditional wrapping hides changes in paragraph-wide diffs. Snapper breaks at sentence boundaries so every edit shows exactly what changed.

Before (traditional wrapping) We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. This approach dramatically reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements.
After (snapper) We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. This approach dramatically reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements.
Without snapper: change one word, diff shows entire paragraph --- a/paper.org +++ b/paper.org @@ -1,3 +1,3 @@ -We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. This approach dramatically reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements. +We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. This approach significantly reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements.
With snapper: same change, diff shows one line --- a/paper.org +++ b/paper.org @@ -1,3 +1,3 @@ We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. -This approach dramatically reduces noise in version control diffs when multiple authors collaborate on a manuscript. +This approach significantly reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements.
snapper sdiff compares files at the sentence level. Whitespace reflow produces zero diff -- only actual content changes appear.
Same one-word change, but diffed at sentence level: $ snapper sdiff paper_v1.org paper_v2.org @@ -1,3 +1,3 @@ We present a method for formatting prose documents with semantic line breaks, where each sentence occupies its own line. -This approach dramatically reduces noise in version control diffs when multiple authors collaborate on a manuscript. +This approach significantly reduces noise in version control diffs when multiple authors collaborate on a manuscript. Our tool handles LaTeX, Org-mode, Markdown, and plaintext with format-aware parsing that preserves structural elements.
Paragraph reflow (rewrapping the same text) produces no diff at all: $ snapper sdiff wrapped_at_80.org semantic_breaks.org No sentence-level differences.

Features

## Built for academic workflows

Everything you need to adopt semantic line breaks across your paper writing toolchain.

### Format-aware parsing

Understands Org-mode, LaTeX, Markdown, RST, and plaintext. Code blocks, math environments, tables, directives, and drawers pass through untouched.

### Abbreviation-aware

Handles Dr., Fig., Eq., e.g., i.e., et al. and 80+ more. Add project-specific abbreviations via `.snapperrc.toml`.

### Pre-commit hook

Ships with `.pre-commit-hooks.yaml`. Enforce semantic line breaks automatically on every commit across your team.

### Editor integration

Stdin/stdout interface works with Emacs Apheleia, vim, and any editor that supports external formatters. Format on save.

### Vale style package

Bundled vale rules flag lines with multiple sentences in your editor. Use `--check` for precise CI enforcement.

### Git smudge/clean filter

Auto-format on commit, transparent to collaborators. Add to `.gitattributes` and formatting happens silently.

### Neural sentence detection

Optional ML-based splitting via nnsplit for 9 languages. Use `--neural --lang de` for non-English text where rules fall short.

### Skip regions with pragmas

Mark hand-formatted text with `snapper:off` / `snapper:on` comments. Poetry, aligned text, and ASCII art pass through untouched.

### One-command setup

`snapper init` detects your formats and generates config, pre-commit hooks, gitattributes, and editor snippets.

Get started

## Install in seconds

Cargo

    # pre-built binary (fastest)
    cargo binstall snapper-fmt
    # or compile from source
    cargo install snapper-fmt

Shell / Homebrew

    # one-liner (Linux/macOS)
    curl -LsSf https://github.com/TurtleTech-ehf/snapper/releases/latest/download/snapper-fmt-installer.sh | sh
    # or Homebrew
    brew install TurtleTech-ehf/tap/snapper-fmt

pip / Nix

    # pip (with maturin wheels)
    pip install snapper-fmt
    # Nix
    nix build github:TurtleTech-ehf/snapper

Pre-commit

    # .pre-commit-config.yaml
    - repo: https://github.com/TurtleTech-ehf/snapper
      rev: v0.3.1
      hooks:
        - id: snapper