On 2019-03-10, Robert Webb wrote: > I noticed a change in behaviour when moving from 7.3 to 8.1, when opening a > line after or before a "// blah" style comment. > > With the cursor on the comment line, it used to be that opening a line above > (with "O") would not insert a comment leader at the start, and same with > opening a line below (with "o"). > > Now it does insert a comment leader in both cases. > > This is never what I want. If I want to extend a comment I hit "A" to append > and hit Enter to start the new line. This inserts the comment leader. I feel > like I'm "in" the comment in this case, as opposed to opening a line "after" > the comment. > > By default, in a C++ file, I have: > > :set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// > > I tried adding a "O" before "://". This prevents the comment leader being > inserted when opening a line above the comment, but NOT when opening a line > below. > > Is that a bug? There appears no way to stop the behaviour when opening a line > below the comment. > > I believe opening a line above or below a //-style comment shouldn't insert > the > comment leader by default. When I do this, my intention is almost always to > insert code after the comment. I can easily continue the comment instead by > appending to it instead.
That's the behavior I want, too. That's controlled by the o flag in 'formatoptions', which is not included by default. I noticed some time ago that several filetype plugins were adding o to 'formatoptions', so I fixed that problem by adding this to my vimrc: autocmd FileType * setlocal formatoptions-=o " Override any filetype plugin's attempt " to set the 'fo' 'o' option. See :help fo-table > Also, how would I easily change "://" to "O://" in my vimrc, without > re-entering the rest of the setting? I guess I want to substitute part of the > value. set comments-=:// set comments+=O:// See :help add-option-flags Regards, Gary -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.