comby
Comby is a powerful command-line tool that allows you to search and replace code patterns across multiple files and directories. It is specifically designed for working with programming languages and is especially helpful for tasks like refactoring, adding new features, and assisting in large-scale codebase maintenance.
Here are a few notable features of Comby:
-
Universal search and replace: Comby supports various code patterns and can perform complex search-and-replace operations, including but not limited to literal matches, regular expressions, and structural queries.
-
Language agnostic: Comby works with a wide range of programming languages, including popular ones like JavaScript, Python, Java, Go, Ruby, and many more. It supports custom grammars for languages not covered by default.
-
Rich query language: Comby provides a query language specifically designed for code patterns, allowing you to express sophisticated search rules. With this language, you can create precise queries to match specific code patterns, making it easier to target specific changes.
-
Open-source and extensible: Comby is an open-source tool, and its codebase is available on GitHub. You can contribute to its development or create your own custom rules and conditions using its extensibility features.
-
Fast and efficient: Comby is built for speed, ensuring quick and efficient search and replace operations even on large codebases. It supports parallel processing and has been optimized for performance.
Comby can be a valuable addition to your development toolkit, helping you automate repetitive tasks, refactor code, and make sweeping changes effectively. Its flexibility and ease of use make it a popular choice for programmers working on complex codebases.
List of commands for comby:
-
comby:tldr:04004 comby: Only perform matching and print matches.$ comby -match-only '${match_pattern}' ""try on your machineexplain this command
-
comby:tldr:47ece comby: Match and rewrite in-place.$ comby -in-place '${match_pattern}' '${rewrite_pattern}'try on your machineexplain this command
-
comby:tldr:f9810 comby: Match and rewrite templates, and print changes.$ comby '${assert_eq!(:[a], :[b])}' '${assert_eq!(:[b], :[a])}' ${-rs}try on your machineexplain this command