[vim/vim] Multi-line Comment Indenting With C -- incorrect initial spacing (#8118)

25 views
Skip to first unread message

cecamp

unread,
Apr 16, 2021, 4:18:40 PM4/16/21
to vim/vim, Subscribed

Describe the bug
Normally, a multi-line comment in C will show a new "*" at the correct indentation every time a carriage return is entered. However, that is not the case with the attached example file. Instead, extra (unwanted) spaces are prepended prior to the asterisk. Removing a line or two from the example file often shows no initial spacing.
(hopefully I've successfully attached cindent-prblm.c and bad.vimrc, because although nominally attached I don't see a confirmation list)

To Reproduce
Detailed steps to reproduce the behavior:

  1. vim -u bad.vimrc cindent-prblm.c
  2. Go to bottom of file: G
  3. Append to bottom of file: o
  4. You'll see that, instead of beginning with " * ", the line begins with a number of unwanted extra spaces: " * "
  5. I will note that deleting a line in the comment area above frequently changes the number of unwanted initial spaces, sometimes yielding no initial spaces; ie. "* "

Expected behavior
It should start with " * " (or some number of spaces following the asterisk).
You can see what it should start with by

  1. vim -u bad.vimrc cindent-prblm.c
  2. Go to 4th line: 4G
  3. Append: o

Environment (please complete the following information):

  • Vim version [e.g. 8.1.1234] (Or paste the result of vim --version.)
    VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 16 2021 16:08:47)
    Included patches: 1-2772
    Compiled by c...@sphinx.fios-router.home
    Huge version with GTK3 GUI. Features included (+) or not (-):
  • OS: [e.g. Ubuntu 18.04, Windows 10 1809, macOS 10.14]
    Scientific Linux release 7.9 (Nitrogen)
  • Terminal: [e.g. GNOME Terminal, mintty, iTerm2, tmux, GNU screen] (Use GUI if you use the GUI.)
    gnome terminal 3.28.2


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Charles Campbell

unread,
Apr 16, 2021, 4:32:27 PM4/16/21
to vim...@googlegroups.com
cecamp (Vim Github Repository) wrote:
>
> *Describe the bug*
> Normally, a multi-line comment in C will show a new "*" at the correct
> indentation every time a carriage return is entered. However, that is
> not the case with the attached example file. Instead, extra (unwanted)
> spaces are prepended prior to the asterisk. Removing a line or two
> from the example file often shows no initial spacing.
> (hopefully I've successfully attached cindent-prblm.c and bad.vimrc,
> because although nominally attached I don't see a confirmation list)
>
> *To Reproduce*
> Detailed steps to reproduce the behavior:
>
> 1. vim -u bad.vimrc cindent-prblm.c
> 2. Go to bottom of file: G
> 3. Append to bottom of file: o
> 4. You'll see that, instead of beginning with " * ", the line begins
> with a number of unwanted extra spaces: " * "
> 5. I will note that deleting a line in the comment area above
> frequently changes the number of unwanted initial spaces,
> sometimes yielding no initial spaces; ie. "* "
>
> *Expected behavior*
> It should start with " * " (or some number of spaces following the
> asterisk).
> You can see what it should start with by
>
> 1. vim -u bad.vimrc cindent-prblm.c
> 2. Go to 4th line: 4G
> 3. Append: o
>
> *Environment (please complete the following information):*
>
> * Vim version [e.g. 8.1.1234] (Or paste the result of |vim --version|.)
> VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 16 2021 16:08:47)
> Included patches: 1-2772
> Compiled by c...@sphinx.fios-router.home
> <mailto:c...@sphinx.fios-router.home>
> Huge version with GTK3 GUI. Features included (+) or not (-):
> * OS: [e.g. Ubuntu 18.04, Windows 10 1809, macOS 10.14]
> Scientific Linux release 7.9 (Nitrogen)
> * Terminal: [e.g. GNOME Terminal, mintty, iTerm2, tmux, GNU screen]
> (Use GUI if you use the GUI.)
> gnome terminal 3.28.2
>
>
Well, that figures. Although I told the tracker to attach the two files,
apparently it didn't. So I'll attach them now on the vimdev mailing
list. Sorry about that...
Chip Campbell
cindent-prblm.c
bad.vimrc

cecamp

unread,
Apr 16, 2021, 4:36:44 PM4/16/21
to vim/vim, Subscribed

Looks like "Attach files by ...selecting..." them did not work. Please see the vimdev mailing list for the two files.

Bram Moolenaar

unread,
Apr 17, 2021, 8:24:31 AM4/17/21
to vim/vim, Subscribed

Your 'cinoptions' ends in "*30", which means Vim will look back only 30 lines for the start of a comment.
But the comment is 32 lines long. Either remove that restriction, or use a larger number. "*50" works fine.

Bram Moolenaar

unread,
Apr 17, 2021, 8:24:32 AM4/17/21
to vim/vim, Subscribed

Closed #8118.

Charles Campbell

unread,
Apr 17, 2021, 3:30:57 PM4/17/21
to vim...@googlegroups.com
Bram Moolenaar (Vim Github Repository) wrote:
>
> Closed #8118 <https://github.com/vim/vim/issues/8118>.
>
Thank you, Bram! I've been suffering with that problem for years -- and
it was just an option I set up years ago. I've now set that parameter to
200...

Chip Campbell
Reply all
Reply to author
Forward
0 new messages