简体   繁体   中英

vim indentation switches for long comment blocks

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM