Skip to content

feat(editing): add Vim-style comment formatting - #307

Merged
fcoury merged 2 commits into
mainfrom
fcoury/comment-formatting
Aug 22, 2026
Merged

fcoury merged 2 commits into
mainfrom
fcoury/comment-formatting

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Comment toggling exists, but long comments still require manual edits or external plugins to reflow and continue them. This adds native Vim-style formatting so comments behave consistently in file buffers and embedded modal textareas.

What Changed

  • Add gq{motion}, gqq/gqgq, counted ranges, and visual gq.
  • Reflow comments and plain text with Unicode-, tab-, indentation-, and CRLF-aware width handling.
  • Preserve documentation leaders such as /// and //! and keep each format operation atomic for undo and redo.
  • Automatically wrap recognized line comments while typing and continue their leaders with Enter, o, and O.
  • Add global and language-specific text_width configuration plus opt-outs for wrapping and continuation.

How to Test

  1. Set [commenting].text_width to a small value, open a Rust comment, and run gqq, gqj, and visual gq; the selected prose should wrap while retaining // or documentation leaders.
  2. Append text to a line comment past the configured width, then press Enter and try o or O; wrapping and new lines should retain the active comment leader and undo as one insert session.
  3. Disable auto_wrap, continue_on_enter, and continue_on_open_line; typing and line creation should fall back to ordinary indentation without adding comment leaders.

Automated coverage is in tests/editing.rs and tests/modal_textarea.rs. The focused comment suite, modal textarea suite, formatter check, and cargo clippy --all-targets --all-features -- -D warnings pass.

@fcoury
fcoury merged commit 68b4a43 into main Aug 22, 2026
11 checks passed
@fcoury
fcoury deleted the fcoury/comment-formatting branch August 22, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants