Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 209
Jacek Krysztofik Avatar asked Jul 21 '10 11:07

Jacek Krysztofik


1 Answers

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.

like image 173
richq Avatar answered Sep 29 '22 04:09

richq