Hugo Hismans
Hugo Hismans

Reputation: 173

Comment formatting, specifying * and indentation

For now my comments are formated like this:

/*
 * comments
 */

When I press /* *return* there is an extra space and *.

I have to respect a convention, so I need that my comments looks like this :

/*
** comments
*/

Does someone know how to configure this in vim?
(During a comment, when I press return, insert "** " instead of " * ")

Upvotes: 2

Views: 236

Answers (1)

sidyll
sidyll

Reputation: 59277

Use the 'comments' option. Please check :h format-comments to read more about this, and configure your options accordingly. Here is a suggestion of flags to use:

s:/*,m:**,ex:*/

This allows easy closing of the comment (x flag) and the middle behavior that you described. You didn't mention the language you're using, but let's assume it is C and Objective-C in which you need this. I like to keep my configuration stuff in my .vimrc; so instead of creating or modifying the language files, I'd add this auto-command:

 autocmd FileType c,objc setlocal comments=s:/*,m:**,ex:*/

Upvotes: 3

Related Questions