diff --git a/README.md b/README.md
index 5d5cb74..d8c3648 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@
- install configured scripts (aka bundle)
- manage runtime path of your installed scripts so you don't have to
- search [all available vim scripts] by name
+- clean up from unused scripts
[Vundle] takes advantage of [vim-scripts.org](http://vim-scripts.org)
in order to install/search [all available vim scripts]
@@ -50,7 +51,7 @@ in order to install/search [all available vim scripts]
:BundleSearch foo
-will split new window with results:
+lists search results in new split window, ie:
Bundle "VimFootnotes"
Bundle "foo.vim"
@@ -59,10 +60,16 @@ so you can just copy ones you need to .vimrc
.
:BundleSearch! foo
-will refresh scripts list before doing search.
+refreshes script list before performing actual search.
Searching requires [curl
](http://curl.haxx.se/)
+## Cleaning up
+
+ :BundleClean
+
+removes unused script dirs from your `.vim/bundle`
+
## Examples
See [gmarik's vimrc](https://github.com/gmarik/vimfiles/blob/1f4f26d42f54443f1158e0009746a56b9a28b053/vimrc#L136) for working example.
diff --git a/autoload/vundle.vim b/autoload/vundle.vim
index e116352..84b4e83 100644
--- a/autoload/vundle.vim
+++ b/autoload/vundle.vim
@@ -6,6 +6,7 @@
com! -nargs=+ Bundle call vundle#config#bundle()
com! -nargs=? -bang BundleInstall call vundle#installer#install("")
+com! -nargs=? BundleClean call vundle#installer#clean()
com! -nargs=0 BundleDocs call vundle#installer#helptags()
com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search("", )
diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim
index 190c7c0..1786d0c 100644
--- a/autoload/vundle/installer.vim
+++ b/autoload/vundle/installer.vim
@@ -42,6 +42,13 @@ func! s:install(bang, bundle)
if synced | call vundle#config#require(a:bundle) | endif
endf
+func! vundle#installer#clean()
+ let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
+ let all_dirs = split(globpath(g:bundle_dir, '*'), "\n")
+ let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
+ for d in x_dirs | exec '!rm -rf "'.escape(d,'"').'"' | endfor
+endf
+
" TODO: make it pause after output in console mode
func! s:log(msg)
if has('gui_running')