Search code examples
vimphpdocauto-indent

vim phpdoc multiline comment autoindent


Suppose I have a comment block like this:

/**
 * comment
 * comment
 * comment
 */

And when I open a new line inside this block I want vim to start it with

/**
 * comment
 * _
 * comment
 * comment
 */

but autoindent in standard (ubuntu) vim scripts starts an empty line, like this:

/**
 * comment
 _
 * comment
 * comment
 */

Is there a modified script or a command that would make vim do that (I remember a few years back I had this functionality, but can't google that right now)?

TIA.


Solution

  • You should add this to your .vimrc:

    set formatoptions+=or
    

    o Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode.

    r Automatically insert the current comment leader after hitting <Enter> in Insert mode.