Comby

Comby

  • Get started
  • Docs
  • Projects & Talks
  • GitHub
  • Blog
Comby Logo

Comby is a tool for searching and changing code structure

Get started

General and lightweight

Use lightweight templates to easily search and change code, HTML, or JSON. Comby is designed to work on any language or data format.

Read the docs →

Language-aware

Perform richer search and replace because Comby understands the syntax of code blocks, strings, and comments for your language.

Install and try →

Find and refactor

Comby is ideal for touching up pieces of code. Use it to translate code like this Python 2 to 3 fixer on the right to replace deprecated methods. Easily write one-off refactors or a collection of quickfixes customized to your project. Comby makes finding and changing code easier than regex alone allows and avoids pitfalls like escaping parentheses, quotes, or multiline changes.

comby 'failUnlessEqual(:[a],:[b])' 'assertEqual(:[a],:[b])' example.py
--- example.py
+++ example.py
@@ -1,6 +1,6 @@
     def test(self):
         r = self.parse("if 1 fooze", 'r3')
-        self.failUnlessEqual(
+        self.assertEqual(
             r.tree.toStringTree(),
             '(if 1 fooze)'
             )
Python 2 to 3 fixers reference↗

Designed to work in the large and in the small

Comby can execute large-scale code changes or let you do an interactive review like codemod. Comby is designed to support every language, and not just the popular ones.

Dedicated parsers refine how Comby understands code, but it also has basic out-of-the-box support for data formats like JSON, recent languages like Zig, or your own DSLs!

Your browser does not support the video tag.

How is Comby used today?

Comby is used in everyday developer workflows and academic research.

Featured blog → Automatically Migrating Eq of No (/=) in HaskellFeatured blog → Automatically Migrating Eq of No (/=) in HaskellProjects and merged changes using CombyProjects and merged changes using Comby

Have you used Comby in one of your projects or have something to share? Point us to your commit or open a PR and get your project featured here.

Parser Parser Combinators for Program Transformation

Link to Comby Strang Loop video

Watch the Strange Loop talk to learn more about Comby.

This talk shares the core ideas and motivation behind Comby, and example uses and applications.

Mini abstract: Regex-based search-and-replace falls short of recognizing program syntax that so often correspond to expressions in code. Many approaches and tools that tackle the problem to overcome the limitations of regex matching but remain underdeveloped for easily changing code. Expressive and powerful transformation frameworks, however, can be hard to learn or use. Comby fills a gap by focusing on lightweight program transformation in every language for every programmer.

© 2022 @rvtond · Get started · Docs · Projects & Talks · Blog · Twitter