(Remove html character entities) |
(add this to duplicate list) |
||
Line 1: | Line 1: | ||
− | {{Duplicate|240|1091|1150}} |
+ | {{Duplicate|240|304|1091|1150}} |
{{review}} |
{{review}} |
||
{{TipImported |
{{TipImported |
Revision as of 10:20, 18 May 2009
Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
created August 10, 2002 · complexity intermediate · author Daniel Bauke · version 6.0
If you'd like to have javadoc folded together with areas in braces try that
set foldmethod=syntax set foldenable syn region foldBraces start=/{/ end=/}/ transparent fold syn region foldJavadoc start=,/\*\*, end=,\*/, transparent fold keepend
and play a bit with:
set foldlevel=0 set foldnestmax=10
parameters
Comments
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
- This works (for braces) because the "keepend" makes sure that any contained items end whenever the braces region ends, whether or not the contained item already ended. The "extend" allows THIS GROUP to override the keepend setting for a container group, so that you can nest this group. For this reason, I doubt very much that you really want to add "extend" to the foldJavadoc group. If you do, javadoc comments become nestable for folding!
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.