sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #653: doxygen '///' :comments setting

 tip karma   Rating 10/7, Viewed by 1177 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   February 10, 2004 9:42      complexity:   intermediate
author:   Michael Brailsford      as of Vim:   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.

- Michael

 rate this tip  Life Changing Helpful Unfulfilling 

<< save all open buffers at once | special characters in VIM substitution >>

Additional Notes

[email protected], February 12, 2004 10:44
I am not all that familiar with vim scripting.  I would like to know how to do exactly this with other comment beginners.  I use the TVO outlining plugin and would like to be able to do this with the | char as the comment line beginner char.  Can anyone help?
hotmail account : dan_j_thompson, March 7, 2004 23:10
This will introduce you to the "comments" string:
:he comments

This will explain how that funky "comments" string is put together:
:he format-comments

Basically, what it will come down to if you'd like to make | a comment character is that you will put something like

:|

into your comments string (separate it from other comment markers with commas).

Look for a comments string (looks like "set comments=....") in a syntax file (like c.vim for C files)...
[email protected], September 18, 2004 10:18
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.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Sponsored by Web Concept Group Inc. SourceForge.net Logo