sponsor Vim development Vim logo Vim Book Ad

clean_imports : Makes use of the Java checkstyle tool to clean your Java file of unused imports

 script karma  Rating 4/1, Downloaded by 694  Comments, bugs, improvements  Vim wiki

created by
Paul Bourke
script type
This is a simple bash script that can be used as a filter in vim to clean your java of unused imports.

If you have the JavaImp plugin installed (vimscript #325) you can use it in conjunction with this to also sort your imports as well as clean them.

I have been using it in my own code and it works quite nicely.  See http://paulbourke.blogspot.com/2012/04/clean-your-java-imports-in-vim.html for more info.
install details
Save the script somewhere in your path such as ~/bin and then add something like the following to your .vimrc

" F7 to call clean redundant Java imports and sort them
function JavaImpClean()
    %!~/bin/clean_imports.sh %
:command JavaImpClean exec JavaImpClean()
:nnoremap <F7> :JavaImpClean<CR>

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
clean_imports.sh 0.1 2012-04-15 7.0 Paul Bourke 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.