splice

Targeted file section replacement

Go File System GitHub

Replace specific line ranges in files. Insert, replace, or delete sections by line number. Safer than full-file rewrites for targeted edits.

Features

  • Replace, insert, or delete by line range
  • Safer than full-file rewrites
  • Dry-run mode for preview
  • Structured JSON output with change summary
  • MCP server and CLI modes

Install

go install github.com/hegner123/splice@latest

The Problem: Editing specific sections of large files

# You need to replace lines 45-60 in a 2000-line file.
# The Edit tool requires matching the exact string content.
# If the content has changed, the edit fails.
# Reading the whole file to find context wastes tokens.

Solution

$ splice --cli --file config.go --start 45 --end 60 --content 'newConfigBlock'

Output

{"file":"config.go","action":"replace","start":45,"end":60,"lines_removed":16,"lines_inserted":1,"new_total":1985}

Comparison

MetricValue
PrecisionLine-range targeting vs full-file rewrite
SafetyDry-run preview available