Remove all comments from source code — as a Neovim plugin and as a standalone CLI tool.
Both tools use Tree-sitter for accurate, AST-based comment detection across many languages.
| Tool | Use case |
|---|---|
| Neovim plugin | Remove comments from the current buffer |
CLI (rmc / remove-comments) |
Remove comments from an entire directory tree |
- Neovim >= 0.9
- nvim-treesitter with parsers installed for your languages
{
"KashifKhn/remove-comments",
config = function()
require("nvim-remove-comments").setup()
end,
}Default keybinding: <leader>rc
Or call directly:
:lua require("nvim-remove-comments").remove_comments()JavaScript, TypeScript, TSX, Lua, Python, Go, Java, C, C++, Rust, HTML, CSS, YAML, TOML, Bash, Dart
A standalone binary that walks a directory tree and removes all comments from every supported source file.
The installer creates both remove-comments and rmc — use whichever you prefer, they are the same binary.
Default behavior is dry-run. No files are modified unless --write is passed.
One-line installer (Linux / macOS)
curl -fsSL https://raw.githubusercontent.com/KashifKhn/remove-comments/main/install.sh | shInstall a specific version:
curl -fsSL https://raw.githubusercontent.com/KashifKhn/remove-comments/main/install.sh | sh -s -- --version 1.0.0Skip modifying shell config:
curl -fsSL https://raw.githubusercontent.com/KashifKhn/remove-comments/main/install.sh | sh -s -- --no-modify-pathManual download
Download a binary for your platform from the releases page, extract, and place it on your PATH.
| Platform | Archive |
|---|---|
| Linux amd64 | remove-comments-linux-amd64.tar.gz |
| macOS amd64 | remove-comments-darwin-amd64.tar.gz |
| macOS arm64 | remove-comments-darwin-arm64.tar.gz |
| Windows amd64 | remove-comments-windows-amd64.zip |
Build from source
Requires Go >= 1.24.
git clone https://github.com/KashifKhn/remove-comments.git
cd remove-comments/cli
go build -o remove-comments .
ln -sf $(pwd)/remove-comments $(dirname $(pwd))/rmcBoth rmc and remove-comments are identical — use either:
# Dry-run: show what would change (no files modified)
rmc .
# Apply changes
rmc --write .
# Target a specific directory
rmc --write ./src
# Process only Go files
rmc --lang go .
# Exclude generated files
rmc --exclude "*.g.dart" .
# Exclude multiple patterns (repeat the flag)
rmc --exclude "*.g.dart" --exclude "*_test.go" .
# Suppress per-file output, show only the summary
rmc --quiet .
# Show a unified diff per changed file
rmc --diff .
# Control parallelism
rmc --jobs 4 .| Flag | Short | Default | Description |
|---|---|---|---|
--write |
-w |
false |
Write changes to disk (default is dry-run) |
--diff |
-d |
false |
Print unified diff for each changed file |
--quiet |
-q |
false |
Print only the final summary line |
--exclude |
-e |
Glob pattern to exclude files (repeatable, e.g. *.g.dart) |
|
--lang |
"" |
Process only files of this language (e.g. go, python) |
|
--jobs |
-j |
NumCPU | Number of parallel workers |
--max-file-size |
10485760 |
Skip files larger than this size in bytes (10 MB) | |
--version |
Print version and exit | ||
--help |
-h |
Print help and exit |
Self-update the binary to the latest release from GitHub.
# Check and upgrade to latest version
rmc upgrade
# Only check for updates (don't install)
rmc upgrade --check
# Force reinstall even if already on latest
rmc upgrade --force
# Upgrade to a specific version
rmc upgrade --version v1.0.3
# JSON output for scripting
rmc upgrade --check --json| Flag | Short | Default | Description |
|---|---|---|---|
--check |
-c |
false |
Only check for updates, do not install |
--force |
-f |
false |
Reinstall even if already on the latest version |
--version |
-v |
"" |
Target a specific version (e.g. v1.0.3) |
--json |
false |
Print result as JSON |
| Language | Extensions |
|---|---|
| JavaScript | .js .mjs .cjs .jsx |
| TypeScript | .ts .tsx |
| Go | .go |
| Python | .py |
| Rust | .rs |
| Java | .java |
| C | .c .h |
| C++ | .cpp .cc .cxx .hpp |
| Lua | .lua |
| HTML | .html .htm |
| CSS | .css |
| YAML | .yaml .yml |
| TOML | .toml |
| Bash | .sh .bash |
| Dart | .dart |
Files with unsupported extensions are skipped. The walker also respects .gitignore rules.
LLM-generated code tends to be full of explanatory comments. This toolset strips them out quickly so you can read and maintain the code without noise.
remove-comments/
├── lua/nvim-remove-comments/ # Neovim plugin (Lua)
├── plugin/ # Neovim autoload entry point
├── install.sh # CLI one-line installer
└── cli/ # Go CLI tool
├── main.go
├── cmd/
└── internal/
├── languages/ # Language → Tree-sitter grammar + query map
├── walker/ # Directory walker with .gitignore support
├── parser/ # Tree-sitter comment range extraction
├── remover/ # Comment removal from source bytes
├── diff/ # Before/after diff computation
├── output/ # Terminal output and summary
└── upgrade/ # Self-update logic (version check, download, install)
