Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Kvdb plugin: Init.

  • Loading branch information...
commit ac32910396a7a7eefc4ce06391b8167c1a0c35e8 1 parent c6201b4
@kalbasit kalbasit authored
View
9 .gitignore
@@ -2,6 +2,9 @@
_backup
_temp
.netrwhist
-autoload/pathogen.vim
-vimius/vim/tools/watchtower
-vimius/vim/langs/mustache
+
+
+# Plugins without git-mirror
+watchtower.vim
+mustache.vim
+kvbd.vim
View
1  README.md
@@ -170,6 +170,7 @@ exist.)
rightwards.
* `<A-]` (`<D-]` on MacVim) Shift current line or selected lines
leftwards.
+* `<C-W>!` Invokes kvdb plugin (Kill Window Delete Buffer, without qutting)
## [Ack.vim](http://github.com/mileszs/ack.vim)
View
64 vimius/vim/tools/kvbd/plugin/kvdb.vim
@@ -0,0 +1,64 @@
+"here is a more exotic version of my original Kwbd script
+"delete the buffer; keep windows; create a scratch buffer if no buffers left
+function s:Kwbd(kwbdStage)
+ if(a:kwbdStage == 1)
+ if(!buflisted(winbufnr(0)))
+ bd!
+ return
+ endif
+ let s:kwbdBufNum = bufnr("%")
+ let s:kwbdWinNum = winnr()
+ windo call s:Kwbd(2)
+ execute s:kwbdWinNum . 'wincmd w'
+ let s:buflistedLeft = 0
+ let s:bufFinalJump = 0
+ let l:nBufs = bufnr("$")
+ let l:i = 1
+ while(l:i <= l:nBufs)
+ if(l:i != s:kwbdBufNum)
+ if(buflisted(l:i))
+ let s:buflistedLeft = s:buflistedLeft + 1
+ else
+ if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump)
+ let s:bufFinalJump = l:i
+ endif
+ endif
+ endif
+ let l:i = l:i + 1
+ endwhile
+ if(!s:buflistedLeft)
+ if(s:bufFinalJump)
+ windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif
+ else
+ enew
+ let l:newBuf = bufnr("%")
+ windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
+ endif
+ execute s:kwbdWinNum . 'wincmd w'
+ endif
+ if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%"))
+ execute "bd! " . s:kwbdBufNum
+ endif
+ if(!s:buflistedLeft)
+ set buflisted
+ set bufhidden=delete
+ set buftype=nofile
+ setlocal noswapfile
+ endif
+ else
+ if(bufnr("%") == s:kwbdBufNum)
+ let prevbufvar = bufnr("#")
+ if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum)
+ b #
+ else
+ bn
+ endif
+ endif
+ endif
+endfunction
+
+command! Kwbd call <SID>Kwbd(1)
+nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR>
+
+" Create a mapping (e.g. in your .vimrc) like this:
+"nmap <C-W>! <Plug>Kwbd
View
10 vimius/vim/tools/tasks/kvbd.rake
@@ -0,0 +1,10 @@
+install_vim_plugin "tools", "kvbd" do
+ download_and_save_file github_raw("telamon/janus/master/plugin/kvbd.vim"),
+ "vimius/vim/tools/kvbd/plugin/kvdb.vim"
+
+ open_and_save_file "vimius/vim/tools/vimius/plugin/kvdb.vim" do
+ <<-EOS
+call vimius#add_mapping('kvbd', 'map', '<C-W>!', '<Plug>Kwbd')
+ EOS
+ end
+end
View
1  vimius/vim/tools/vimius/plugin/kvdb.vim
@@ -0,0 +1 @@
+ call vimius#add_mapping('kvbd', 'map', '<C-W>!', '<Plug>Kwbd')
Please sign in to comment.
Something went wrong with that request. Please try again.