Vim でスワップファイルの削除

大量にファイルを開いている時に Vim が死ぬととても悲しい事になるので簡単な Vim script を書きました。

[ソース]

function! s:remove_swapfile()
    let target = &directory
    let list = split(glob(target."**/*.*.sw{p,o}"), '\n')
    echo "remove"
    for file in list
        echo file
        call delete(file)
    endfor
endfunction
command! RemoveSwapfile :call <SID>remove_swapfile()

[コマンド]

:RemoveSwapfile