Wikia

Vim Tips Wiki

Changes: Continuing doxygen comments

Edit

Back to page

(Comments: with ^= no need to remove and readd ://)
(Change <tt> to <code>, perhaps also minor tweak.)
Line 4: Line 4:
 
|previous=652
 
|previous=652
 
|next=654
 
|next=654
|created=February 10, 2004
+
|created=2004
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Michael Brailsford
 
|author=Michael Brailsford
Line 12: Line 12:
 
|category2=Options
 
|category2=Options
 
}}
 
}}
This will continue lines of <tt>///</tt> [http://www.doxygen.org doxygen] comments when you reach the end of a line while typing a comment. It also works if you use <tt>o</tt> to open a new line while on a comment starting with <tt>///</tt>. It only works if there is a space between the last <tt>/</tt> and the first letter of the comment, that is no big deal, since it lends itself to readability. So for example:
+
This will continue lines of <code>///</code> [http://www.doxygen.org doxygen] comments when you reach the end of a line while typing a comment. It also works if you use <code>o</code> to open a new line while on a comment starting with <code>///</code>. It only works if there is a space between the last <code>/</code> and the first letter of the comment, that is no big deal, since it lends itself to readability. So for example:
   
 
<pre>
 
<pre>

Revision as of 05:41, July 13, 2012

Tip 653 Printable Monobook Previous Next

created 2004 · complexity intermediate · author Michael Brailsford · version 6.0


This will continue lines of /// doxygen comments when you reach the end of a line while typing a comment. It also works if you use o to open a new line while on a comment starting with ///. It only works if there is a space between the last / and the first letter of the comment, that is no big deal, since it lends itself to readability. So for example:

/// This will work.
///This won't.

Here is the magic line. Make sure you put it somewhere that will get sourced whenever you open a file you want to use with doxygen. I have it in ~/.vim/after/ftplugin/c/c.vim, so it gets sourced for all C and C++ files.

set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,bO:///,O://

All other comments will continue to work as expected.

References

Comments

I use:

set comments-=://
set comments+=:///,://

True, it puts them at the end of the comment expression list, but I don't think that will be a problem. This way, I don't have to worry about any other comment expressions that may be present.

Keep in mind that loading a new syntax file overwrites whatever you have set "comments" to be. Add this to your vimrc if you don't want to keep retyping "set comments..."

autocmd FileType c,cpp set comments-=://
autocmd FileType c,cpp set comments+=://!
autocmd FileType c,cpp set comments+=://

I think, for the .vimrc, the post just above should read:

autocmd FileType c,cpp set comments-=://
autocmd FileType c,cpp set comments+=:///
autocmd FileType c,cpp set comments+=://

That's what worked for me. - Chris B


Or just use ^= instead of += to prepend the new option:

autocmd Filetype c,cpp set comments^=:///

Around Wikia's network

Random Wiki