Bug in vim script 'comments'?

12 views
Skip to first unread message

Gary Johnson

unread,
Feb 19, 2021, 6:32:35 PM2/19/21
to vim...@googlegroups.com
A change was made to the 'comments' setting in ftplugin/vim.vim at
commit 7ff78465f7057a672a6de0d75d56286da253501b (between 8.2.1175
and 8.2.1176) that introduced a change in formatting behavior that
I think is a bug.

The setting of the 'comments' option was changed from this:

setlocal com=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\"

to this:

setlocal com=sO:\"\ -,mO:\"\ \ ,sO:#\ -,mO:#\ \ ,eO:##,:\",:#

It appears that the purpose was to add # as a comment leader for
Vim9, but the change also removed the end string of the original
three-piece comment definition for the " comment leader.

The problem this causes is that when entering a comment containing
an indented line that contains a ", the comment leader is not
automatically inserted at the start of the next line. Here is an
example, with 'filetype' set to "vim".

" When these lines are ended by pressing <Enter>,
" a " is automatically inserted at the start of
" each next line. This is good.
"
" This line is indented. Pressing <Enter> here
" also automatically starts this line with ".
But because of that second " in the line above, this line
did not start with a ". The comment was terminated. This
is bad.

The attached patch should fix the problem. The patch was made
against Vim 8.2.2519.

Regards,
Gary
vim.vim.patch

Bram Moolenaar

unread,
Feb 20, 2021, 2:30:46 AM2/20/21
to vim...@googlegroups.com, Gary Johnson
Thanks for reporting, I'll include the fix.


--
TALL KNIGHT: When you have found the shrubbery, then you must cut down the
mightiest tree in the forest ... with a herring.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages