Jacek Krysztofik
Jacek Krysztofik

Reputation: 1366

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.

Upvotes: 5

Views: 1179

Answers (3)

richq
richq

Reputation: 56458

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.

Upvotes: 8

vincentkriek
vincentkriek

Reputation: 322

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).

Upvotes: 0

ashnazg
ashnazg

Reputation: 6688

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

Upvotes: 0

Related Questions