vim indentation switches for long comment blocks

时间:2016-10-20 18:51:24

标签: vim indentation

Having nothing in my vimrc but

filetype plugin indent on

I get some strange indentation behavior I can't sort out. When typing a long block comment such as

/**
  *
  *
  *
  */

The * comment is automatically added every time I write a new line as expected. However, after 72 lines of this the indentation decides to change:

[a bunch of other comment lines above this]
 * Line 70
 * Line 71
* Line 72
* Line 73

Suddenly the indentation switches for no reason! I noticed this when I tried formatting a block of comments by visual selection and then hitting =, which completely messed it all up. I don't understand why this happens after a prescribed number of comment lines.

Can someone explain this? I thought it must be something in my vimrc, but after switching everything off I think it's just part of how vim indents things. I tried using filetype plugin on instead, which seemed to work as I typed the comment, but selecting and then indenting through = gave the same result.

1 个答案:

答案 0 :(得分:0)

I could reproduce this bug in vim 7.4.2143, I can't explain it, but if you use:

filetype plugin on

instead of:

filetype plugin indent on

it does not stop indenting at line 72. I hope this knowledge helps you.