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 967  Comments, bugs, improvements  Vim wiki

created by
Paul Bourke
 
script type
utility
 
description
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 %
    :JavaImpSort
endfunction
: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: 216.73.216.107

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github