Vim Tips Wiki
m (Doxygen '///' moved to Continuing doxygen comments: Page moved by JohnBot to improve title)
m (Reverted edits by 180.254.234.211 (talk | block) to last version by JohnBot)
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=653
 
|id=653
  +
|previous=652
|title=doxygen '///'
 
  +
|next=654
|created=February 10, 2004 9:42
+
|created=2004
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Michael Brailsford
 
|author=Michael Brailsford
 
|version=6.0
 
|version=6.0
 
|rating=6/6
 
|rating=6/6
  +
|category1=C++
|text=
 
  +
|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 work.
 
 
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:
///This won't.
 
   
  +
<pre>
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.
 
 
/// This will work.
set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,bO:///,O://
 
 
///This won't.
  +
</pre>
   
 
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.
All other comments will continue to work as expected.
 
   
  +
<pre>
- Michael
 
 
set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,bO:///,O://
}}
 
  +
</pre>
  +
 
All other comments will continue to work as expected.
   
 
==References==
 
==References==
Line 25: Line 31:
 
*{{help|format-comments}}
 
*{{help|format-comments}}
   
== Comments ==
+
==Comments==
 
I use:
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 <tt>|</tt> char as the comment line beginner char. Can anyone help?
 
   
  +
<pre>
allanneal--AT--myrealbox.com
 
 
set comments-=://
, February 12, 2004 10:44
 
 
set comments+=:///,://
----
 
  +
</pre>
Basically, what it will come down to if you'd like to make <tt>|</tt> a comment character is that you will put something like
 
:|
 
   
 
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.
into your comments string (separate it from other comment markers with commas).
 
  +
  +
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..."
   
  +
<pre>
Look for a comments string (looks like "set comments=....") in a syntax file (like c.vim for C files)...
 
  +
autocmd FileType c,cpp set comments-=://
  +
autocmd FileType c,cpp set comments+=://!
  +
autocmd FileType c,cpp set comments+=://
  +
</pre>
   
hotmail account : dan_j_thompson
 
, March 7, 2004 23:10
 
 
----
 
----
I use:
 
set comments-=://
 
set comments+=:///,://
 
   
  +
I think, for the .vimrc, the post just above should read:
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.
 
  +
  +
<pre>
  +
autocmd FileType c,cpp set comments-=://
  +
autocmd FileType c,cpp set comments+=:///
  +
autocmd FileType c,cpp set comments+=://
  +
</pre>
  +
  +
That's what worked for me. - Chris B
   
paxunix--AT--acm.org
 
, September 18, 2004 10:18
 
 
----
 
----
<!-- parsed by vimtips.py in 0.296326 seconds-->
 
   
  +
Or just use ^= instead of += to prepend the new option:
[[Category:C plus plus]]
 
  +
[[Category:Options]]
 
  +
<pre>
  +
autocmd Filetype c,cpp set comments^=:///
  +
</pre>

Revision as of 17:16, 17 July 2014

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^=:///