Vim phpdoc multiline comment autoindent

Suppose I have a block of comments like:

/**
 * 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 the standard (ubuntu) vim scripts starts an empty line, for example:

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

Is there a modified script or command that would force vim to do this (I remember a few years ago, I had this functionality, but I can’t do it now by Google)?

TIA.

+5
source share
3 answers

You should add this to your .vimrc:

set formatoptions+=or

o Automatically insert the current commentator after hitting 'o' or 'O' in normal mode.

r     < & Enter GT; .

+8
0

He does it for me, and I see what that means, but I could not find him. Setting a compatible mode (so that it acts like vi, you don't want it) kills it, so maybe setting nocompatible in your vimrc might fix it ( set nocompatible).

0
source

All Articles