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.
Language-aware
Perform richer search and replace because Comby understands the syntax of code blocks, strings, and comments for your language.
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)'
)
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!
Comby is used in everyday developer workflows and academic research.
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.
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.