hdl
hdl

Reputation: 1038

Why doesn't Vim indent correctly long C style comments?

I cannot figure why vim (7.4.52 on Ubuntu 14.04 LTS) is indenting long C style comments like this (see below), while emacs indents it right.

/* looong comment
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
* <- wrong indentation begins at comment line 72
* and keeps being wrong until the end of comment
*/

/*
 * <- back to normal until line 72
 */

FWIW, here is what :setl tells me:

  autoindent          cryptmethod=        expandtab           include=          nomodeline            shiftwidth=4        tags=
--autoread            define=             filetype=c          keywordprg=         path=               softtabstop=4
  cindent             errorformat=        grepprg=            makeprg=            scroll=22           syntax=c
  cinoptions=:0,(0,u0,U0
  comments=sO:* -,mO:*  ,exO:*/,s1:/*,mb:*,ex:*/,://
  fileencoding=utf-8
  formatoptions=croql
  omnifunc=ccomplete#Complete

Any idea why or how to correct this behaviour? Is this a Vim bug?

Upvotes: 2

Views: 77

Answers (1)

tivn
tivn

Reputation: 1923

To allow longer comment, you can specify this with cinoptions like this: set cinoptions+=*200. The default value is 70. See help cino-star.

Upvotes: 2

Related Questions