sponsor Vim development Vim logo Vim Book Ad

java_fold : Folding expression for Java

 script karma  Rating 2/2, Downloaded by 1028    Comments, bugs, improvements  Vim wiki

created by
Jorrit Wiersma
script type
This script uses the expr fold-method to create folds for java source code.  Folds are created for methods, variables and nested classes with a javadoc comment (that is, at any line inside a class that starts with /**).  The fold will show a count of the number of lines contained in it and the first line of the variable or method declaration.

The fold level for each fold is equal to the indentation divided by the value of the 'shiftwidth' option, so make sure that 'shiftwidth' is set to the right value for your code.

- this doesn't work if you don't indent your code (properly) or if you don't use javadoc comments
- the folds are "greedy": they start at a javadoc comment and run upto the next javadoc comment (they don't pay attention to syntax)
- you can't see the javadoc comments in the folds
install details
Either save the script in a file and source that file whenever you want to use the folding, or save it in your ftplugin directory (for example, ~/.vim/ftplugin) and it should load every time you edit java code.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
java_fold.vim 1.1 2005-07-13 6.0 Jorrit Wiersma Added line counts to the fold text (contributed by Robert Ames)
java_fold.vim 1.0 2005-06-21 6.0 Jorrit Wiersma Initial upload
ip used for rating:

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.
SourceForge.net Logo