Tip #304: fold braces and javadoc
tip karma |
Rating 174/49, Viewed by 3578
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
August 10, 2002 4:47 |
|
complexity: |
|
intermediate |
author: |
|
Daniel Bauke |
|
as of Vim: |
|
6.0 |
If you'd like to have javadoc folded together with areas in braces try that
<pre>
set foldmethod=syntax
set foldenable
syn region foldBraces start=/{/ end=/}/ transparent fold
syn region foldJavadoc start=,/\*\*, end=,\*/, transparent fold keepend
</pre>
and play a bit with:
<pre>
set foldlevel=0
set foldnestmax=10
</pre>
parameters
<< Statusline Tab Level Function Ruler TVIM |
Best of VIM Tips (VIM's best Features) >>
Additional Notes
niklasl,
September 10, 2004 7:48
|
This is great, but I had a lot of problems with it (brace-folds kept folding to the end of the class etc). It seems that my settings for java highlighting (e.g. ``let java_highlight_functions="style"``) have a lot to do with it. So I did some changes.
I cannot really explain exactly why the following works, but it does for me:
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
syn region foldJavadoc start=+/\*+ end=+\*/+ transparent fold keepend extend
I also added folding for import statements. This could probably be a lot cleaner; still, here goes:
syn keyword javaExternal native package
syn region foldImports start=/\(^\s*\n^import\)\@<= .\+;/ end=+^\s*$+ transparent fold keepend
Notably the ``\n`` in the start of ``foldImports`` and the redefinition of ``javaExternal`` (so that ``import`` will match) seem quite nasty. If you have a better solution for this, please share them here.
|
Anonymous,
February 4, 2006 22:18
|
this rocks
|
|