Apply small rewrites to tweak or refactor your files
  • OCaml 95.1%
  • Shell 2.6%
  • Dune 1.8%
  • Makefile 0.5%
Find a file
2026-09-08 12:13:51 +02:00
.github Upgrade OCaml and dune in CI 2026-08-12 14:47:13 +02:00
.vscode Improve final newline handling in vscode 2026-02-24 09:00:21 +01:00
src Improve myers and merge3 vendoring 2026-08-17 16:51:31 +02:00
test Vendor ocaml-merge3 2026-05-18 16:14:25 +02:00
third-party-license Improve myers and merge3 vendoring 2026-08-17 16:51:31 +02:00
.gitattributes Initialize empty libs & licence 2024-09-03 13:55:12 +02:00
.gitignore Ignore local coverage script 2025-06-27 11:36:07 +02:00
.headache.config Initialize empty libs & licence 2024-09-03 13:55:12 +02:00
.ocamlformat Upgrade ocamlformat to 0.29.0 2026-03-24 09:09:35 +01:00
CHANGES.md Edit changelog 2025-12-24 10:14:04 +01:00
CODE_OF_CONDUCT.md Adopt OCaml Code of Conduct 2024-11-10 19:56:04 +01:00
CODEOWNERS Initiate code owners file for GH 2026-02-01 16:16:25 +01:00
COPYING.HEADER Modernize license headers 2026-03-17 13:23:30 +01:00
dune Initialize empty libs & licence 2024-09-03 13:55:12 +02:00
dune-project Let opam figure out the relevant bound for ppxlib 2026-05-18 16:24:28 +02:00
dune-workspace.5.2 Upgrade CIs 2026-04-12 13:20:18 +02:00
dune-workspace.5.3 Upgrade CIs 2026-04-12 13:20:18 +02:00
dune-workspace.5.4 Upgrade CIs 2026-04-12 13:20:18 +02:00
dune-workspace.5.5 Upgrade CI to 5.5.1 2026-09-08 12:13:51 +02:00
dunolint Add dunolint workflow 2025-12-12 13:54:08 +01:00
file-rewriter-dev.opam Let opam figure out the relevant bound for ppxlib 2026-05-18 16:24:28 +02:00
file-rewriter-tests.opam Let opam figure out the relevant bound for ppxlib 2026-05-18 16:24:28 +02:00
file-rewriter-tests.opam.template Add opam template file and configure more fields 2024-12-02 13:21:58 +01:00
file-rewriter.opam Simplify dependencies 2025-12-23 11:16:52 +01:00
file-rewriter.opam.template Add opam template file and configure more fields 2024-12-02 13:21:58 +01:00
headache.sh Remove left-over unused var (shellcheck) 2026-03-17 12:02:10 +01:00
LICENSE Initialize empty libs & licence 2024-09-03 13:55:12 +02:00
Makefile Initialize empty libs & licence 2024-09-03 13:55:12 +02:00
NOTICE.md Improve myers and merge3 vendoring 2026-08-17 16:51:31 +02:00
README.md Fix some typos 2026-05-18 16:46:53 +02:00
sexps-rewriter.opam Update dependencies 2025-06-06 09:21:17 +02:00
sexps-rewriter.opam.template Add opam template file and configure more fields 2024-12-02 13:21:58 +01:00

file-rewriter

CI Status Coverage Status

File-rewriter is an OCaml library for applying small rewrites to tweak or refactor your files. It provides a convenient interface to apply surgical textual substitutions on the fly, while navigating the contents of a file through an abstract representation containing code locations.

Other libraries

The repository also contain sexps_rewriter, a specialized version of the main library dedicated to rewriting sexp files.

Motivation

We created these libraries as part of an ongoing work to create linting and refactoring tools for the many dune files found in big monorepos (see dunolint).

Acknowledgments

We've been inspired by this blog post.

In particular, we've reused the idea of registering substitutions while itering through the locations of an AST. While we didn't reuse any particular project or existing code for our libraries, we're thankful to Jeremie Dimino and Jane Street for the work and techniques discussed in their blog post.