Linux command
comby 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Simple replacement
comby 'console.log(:[arg])' 'logger.info(:[arg])' [.js]
Replace in directory
comby 'foo(:[x])' 'bar(:[x])' [src/] -matcher [.py]
Preview changes
comby 'old' 'new' -match-only
Interactive review
comby 'pattern' 'replacement' -review
In-place modification
comby 'old' 'new' -in-place [file.go]
Diff output
comby 'old' 'new' -diff [file.js]
说明
comby is a structural code search and replace tool for any language. Uses lightweight templates with holes (:name) to match code structures. Understands syntax of code blocks, strings, and comments.
参数
- -matcher _ext_
- File extension matcher (.py, .js, etc.)
- -match-only
- Only show matches, don't rewrite
- -in-place
- Modify files in place
- -diff
- Show unified diff output
- -review
- Interactive review mode
- -stdin
- Read from stdin
- -stdout
- Write to stdout
- -count
- Count matches only
- -d _dir_
- Target directory
FAQ
What is the comby command used for?
comby is a structural code search and replace tool for any language. Uses lightweight templates with holes (:name) to match code structures. Understands syntax of code blocks, strings, and comments.
How do I run a basic comby example?
Run `comby 'console.log(:[arg])' 'logger.info(:[arg])' [.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -matcher _ext_ do in comby?
File extension matcher (.py, .js, etc.)