rust-lang / rust-lang/rust-analyzer
[bug] Split/merge operations on module-level comments (`//!`) don't work as expected
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Rust-Analyzer doesn't seem to correctly operate on //! comments, which makes it hard to write module-level documentation and examples. I'm not sure if this is specifically an interaction between vscode.vim and RA, or general to the way RA works. But this did seem to work correctly when I still used RLS + vim.
Issues
The two main issues I encounter regularly are:
- Splitting a long line into multiple lines using
Vgq. This inserts a//comment instead of a//!comment. - Merging two shorter lines into a single line using
Vjgq. This merges the lines, but leaves in a stray!character.
Example
Both issues we've mentioned can be seen here. First we split a long line into multiple lines, which doesn't correctly insert a //! comment. And then we merge two shorter lines into a single line, which leaves a stray ! in the merged line.

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two reported cases in a Rust module containing //! comments, using Vgq to split a long line and Vjgq to merge lines with the vscode.vim setup. Compare the results with the expected //! comments: splitting should preserve the prefix, and merging should not leave a stray !.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100