Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

brought file from dotfiles

  • Loading branch information...
commit 4831ef55125bfd4b9bfa45610fe4005d5e36283b 0 parents
Jonathan Lipps authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 plugin/bda.vim
39 plugin/bda.vim
@@ -0,0 +1,39 @@
+" Bda - Delete all open buffers.
+
+command! -nargs=0 -bang Bda
+ \ :call BufDeleteAll('<bang>')
+
+function! BufDeleteAll(bang)
+ let last_buffer = bufnr('$')
+
+ let n = 1
+ while n <= last_buffer
+ if a:bang == '' && getbufvar(n, '&modified')
+ echohl ErrorMsg
+ echomsg 'No write since last change for buffer'
+ \ n '(add ! to override)'
+ echohl None
+ return 0
+ endif
+ let n = n+1
+ endwhile
+
+ let delete_count = 0
+ let n = 1
+ while n <= last_buffer
+ if buflisted(n)
+ silent exe 'bdel' . a:bang . ' ' . n
+ if ! buflisted(n)
+ let delete_count = delete_count+1
+ endif
+ endif
+ let n = n+1
+ endwhile
+
+ if delete_count == 1
+ echomsg delete_count "buffer deleted"
+ elseif delete_count > 1
+ echomsg delete_count "buffers deleted"
+ endif
+
+endfunction
Please sign in to comment.
Something went wrong with that request. Please try again.