Tip #143: Use of Vim folds for javadocs
tip karma |
Rating 28/12, Viewed by 2965
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
October 20, 2001 6:18 |
|
complexity: |
|
basic |
author: |
|
sameer chabungbam |
|
as of Vim: |
|
6.0 |
Hi,
The fold-method marker can be effectively use to set the folds in your Java source. Define some marker and place it inside HTML comments <!-- xx -->. This way, it does not affect the Javadocs generated without the necessity of a seprate comment line.
e.g.
/**
* <!-- zz.FOLDSTART class AbcClass -->
* The class description.
* ...
*/
public class AbcClass {
/**
* <!-- method zz.FOLDSTART someMethod() -->
* Method description.
*/
public void someMethod();
...
} /* zz.END: AbcClass */
/* Put this at the end of your file */
/* vim:fdm=marker fmr=zz.FOLDSTART,zz.END fdl=2 fdc=2: */
Now, the files will be opened with the methods neatly folded.
You can use "zR" to open all folds (or click on the "+" at the left column).
Sameer.
<< Automatic function end commenting for C++ and Java |
recording keystrokes by "q" for repested jobs >>
Additional Notes
[email protected],
July 11, 2002 6:43
|
Another thing you might try, if you don't feel like mucking up your code by adding markers everywhere(I really love folding but I don't like the idea of having to modify my sources to get it to work just right) is to set your foldmarker to the javadoc comment blocks:
fdm=/**,*/
Seems to work pretty well, doesn't interfere with normal /* */ chunks anyway.
|
Koenraad Heijlen,
July 26, 2002 13:28
|
Really nice folding on /** */ if you are editing source that's overcommented....
I use these settings to autoload java files :
autocmd FileType java :set fmr=/**,*/ fdm=marker fdc=1
|
Eric Bowman,
July 30, 2002 14:38
|
It seems like the last idea is a bit buggy. Not all javadoc comments fold automatically, and some really weird behavior results. But the following works like a charm:
In java.vim, change the javaDocComment line to:
syn region javaDocComment start="/\*\*" end="\*/" transparent fold keepend contains=javaCommentTitle,@javaHtml,javaDocTags,javaTodo,@Spell
(added "transparent fold").
Then in my .vimrc I added:
set foldmethod=syntax
Voila! No more annoying javadoc comments everywhere...
|
Eric Bowman,
July 30, 2002 14:48
|
Oops, you probably want to leave the "transparent" out...it changes your javadoc colors to white! I misunderstood the very :help syn-fold.
|
itsmangesh at gmail dot com,
March 2, 2005 23:14
|
Thanks,
Thats wonderful, and thats what I was looking for :-)
|
|