Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Doxygen support - auto asterisk (*) insertion on newline

Tags:

c++

c

vim

doxygen

When I write Doxygen comments (in C file) I would like an asterisk to be automatically inserted on new line (either with the o command or just ↩ ).

Like this example :

/** 
 * My Doxygen comment being written

And when I hit ↩

/**
 * My Doxygen comment bein written
 * 
   ^
 cursor is here

I have DoxygenToolkit.vim and set syntax=c.doxygen but none does what I want. I also found that but not sure what it is supposed to do, but doesn't solve my problem. I've googled for it but did not find.

Any idea?

like image 250
Quentin Avatar asked Jun 05 '14 11:06

Quentin


2 Answers

You need this in your ~/.vimrc:

filetype plugin indent on

I don't know about DoxygenToolkit.vim, I have never used it. The above is all it takes to enable the described behaviour in my 7.x Vims.

You can find my commented ~/.vimrc online. Nothing too fancy in there, just what I use every day on half a dozen different Linux / AIX boxes. Perhaps there is more in there that you would like.

like image 136
DevSolar Avatar answered Nov 14 '22 22:11

DevSolar


:setlocal formatoptions+=ro

does that (:help fo-table).

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.

Put this into ~/.vim/after/ftplugin/c.vim. (This requires that you have :filetype plugin on; use of the after directory allows you to override any default filetype settings done by $VIMRUNTIME/ftplugin/c.vim.) Alternatively, you could define an :autocmd FileType c ... directly in your ~/.vimrc, but this tends to become unwieldy once you have many customizations.

like image 20
Ingo Karkat Avatar answered Nov 14 '22 21:11

Ingo Karkat