On 2011-05-31, Fab wrote:
> Hi,
> I'm reporting a very strange behavior I have only noticed today on
> vim.
> If you open a C file (vim foo.c) and enter this text:
> /*
> then press ENTER
> vim will automatically align the comment and will insert automatically
> a space, star, space: ' * ' before every line.
> 
> Unfortunately after 72 lines, this sort of convenient indentation
> capability stop working:
> vim insert only a star (no spaces), and sometimes (if previous text
> has some sort of indentation, it insert several spaces)
> 
> If you have a simple (empty) comment with 72 empty lines is not too
> bad as after 1 wrong line it appears to recover, but on one case I
> have a long text with various text indented: in this case vim keep
> inserting several empty lines with no apparent reason. I had to break
> my long comment section into two sections...
> 
> Tested with vim 7.0 on Linux (CentOS 5.x), MacVim 7.2, buit-in Mac OS
> vim, and gvim on Mac (7.1).
> To reproduce it, the simplest thing is to open a file called foo.c,
> enter '/*' + enter and repeat pressing enter until you see the
> problem.
> 
> In my .vimrc I have:
> ------------------------------------
> filetype plugin on
> filetype indent on
> -----------------------------------------
> 
> Any idea why?

Interesting.  I don't know why it does that, but I did discover
this, using Vim 7.3.189 on a Linux system.

    $ vim -N -u NONE
    :set nu
    :set fo+=r

Add "/*" then press and hold Enter.  I stopped at 300 lines.  All
lines after the first contained the desired " *".  Restart vim.

    $ vim -N -u NONE
    :set nu
    :set fo+=r
    :let &rtp = $VIMRUNTIME
    :filetype indent on
    :set ft=c
    :scriptnames
      1: $VIMRUNTIME/filetype.vim
      2: $VIMRUNTIME/indent.vim
      3: $VIMRUNTIME/indent/c.vim

Again add "/*" and press and hold Enter.  This time the comment
leader changes from " *" to "*" at line 72.

The culprit appears to be $VIMRUNTIME/indent/c.vim, but it contains
only

    setlocal cindent

So,...

    $ vim -N -u NONE
    :set nu
    :set fo+=r
    :set cindent

Again add long comment block.  Sure enough, after 71 lines the
comment leader changes from " *" to "*".

So, Vim formats C comments whether or not 'cindent' is set, but it
does so incorrectly if 'cindent' is set.

Regards,
Gary

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to