Zend certified PHP/Magento developer

vim: don’t auto-extend c/c++ trailing comments

Use vim to edit this C++ excerpt.

// line 1
int xxxxxxxx = 0; // line 2
int yyyyyyyy = 0;

When the cursor is in line 1 and you hit o to insert a line below it, vim conveniently starts the new line with another // comment.

When the cursor is in line 2 and you do the same, the new line begins with //,
i.e., a comment aligned with line 2’s trailing comment.
This is unhelpful if you prefer block (multiline) comments to not be deeply indented. A trailing comment is more likely to be two or three words sufficient unto itself, than the unfinished start of a long paragraph.

Can inserting below line 2 begin without an automatically added comment mark (like inserting below line 3), while preserving line 1’s behavior?

In C++, set comments? reports comments=sO:* -,mO:* ,exO:*/,s1:/*,mb:*,ex:*/,:///,://. This is for vim 9.0, on both Ubuntu 22.04 and macOS 13.4.1.

(The offending line-2 behavior happens with // also in C, but not with # in bash, php, ruby, etc; and not with // in php).