views:

35

answers:

3

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.

A: 

It's possible that PDV (phpDocumentor for Vim) handles that -- http://www.vim.org/scripts/script.php?script_id=1355

ashnazg
A: 

It does that for me, and I have been looking into what does that, but I can't seen to find it. Setting compatible mode (so it acts like vi, you don't want that) kills it so maybe setting nocompatible in your vimrc might fix it (set nocompatible).

vincentkriek
A: 

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.

rq
That helped, thanks a bunch.
rishta