From 64f5be8dd858e0cf0d61a5887d02802d5e92d47c Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sat, 13 Apr 2013 15:59:01 +0200 Subject: [PATCH 01/22] Add option to show unnamed bufs in CtrlP's fashion The unnamed buffers are shown as "[{NR}*No Name]", just like in the CtrlP plugin. --- README.md | 3 ++- plugin/bufferlist.vim | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 18594a7..21fcb3e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ one expects. Buffers that are visible (in any window) are marked with `*`, ones that are modified are marked with `+`. -To delete a buffer from the list (i.e. close the file) press `d`. +To delete a buffer from the list (i.e. close the file) press `d`. Usage ----- @@ -31,6 +31,7 @@ like this in your `~/.vimrc`: ### Optional + let g:BufferListShowUnnamed = 1 let g:BufferListWidth = 25 let g:BufferListMaxWidth = 50 hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index fedb730..9b56f5c 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -20,6 +20,7 @@ "= NEEDED: = "= map :call BufferList() = "= OPTIONAL: = +"= let g:BufferListShowUnnamed = 1 = "= let g:BufferListWidth = 25 = "= let g:BufferListMaxWidth = 50 = "= hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold = @@ -39,6 +40,10 @@ if !exists('g:BufferListMaxWidth') let g:BufferListMaxWidth = 40 endif +if !exists('g:BufferListShowUnnamed') + let g:BufferListShowUnnamed = 0 +endif + " toggled the buffer list on/off function! BufferList() " if we get called and the list is open --> close it @@ -58,6 +63,11 @@ function! BufferList() " iterate through the buffers let l:i = 0 | while l:i <= l:bufcount | let l:i = l:i + 1 let l:bufname = bufname(l:i) + + if g:BufferListShowUnnamed && !strlen(l:bufname) + let l:bufname = '[' . l:i . '*No Name]' + endif + if strlen(l:bufname) \&& getbufvar(l:i, '&modifiable') \&& getbufvar(l:i, '&buflisted') @@ -102,7 +112,7 @@ function! BufferList() let l:i = 0 | while l:i < l:width | let l:i = l:i + 1 let l:fill = ' ' . l:fill endwhile - + " now, create the buffer & set it up exec 'silent! ' . l:width . 'vne __BUFFERLIST__' setlocal noshowcmd @@ -143,7 +153,7 @@ function! BufferList() " set up the keymap noremap :call LoadBuffer() - map q :bwipeout + map q :bwipeout map j :call BufferListMove("down") map k :call BufferListMove("up") map d :call BufferListDeleteBuffer() From 59b120c9f9bff37f8fd747c907d48e28b34d9e78 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 18 Apr 2013 06:41:18 +0200 Subject: [PATCH 02/22] Add a function deleting all hidden buffers --- README.md | 2 ++ plugin/bufferlist.vim | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 21fcb3e..876accf 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ modified are marked with `+`. To delete a buffer from the list (i.e. close the file) press `d`. +To delete all hidden buffers (the ones not visible in any tab) press `D`. + Usage ----- diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 9b56f5c..0ec24ec 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -157,6 +157,7 @@ function! BufferList() map j :call BufferListMove("down") map k :call BufferListMove("up") map d :call BufferListDeleteBuffer() + map D :call BufferListDeleteHiddenBuffers() map :call BufferListMove("up") map :call BufferListMove("down") map @@ -265,6 +266,30 @@ function! BufferListDeleteBuffer() call BufferList() endfunction +" deletes all hidden buffers +" taken from: http://stackoverflow.com/a/3180886 +function! BufferListDeleteHiddenBuffers() + " figure out which buffers are visible in any tab + let l:visible = {} + for t in range(1, tabpagenr('$')) + for b in tabpagebuflist(t) + let l:visible[b] = 1 + endfor + endfor + " kill the buffer list + bwipeout + " close any buffer that are loaded and not visible + let l:tally = 0 + for b in range(1, bufnr('$')) + if buflisted(b) && !has_key(l:visible, b) + let l:tally += 1 + exe ':bdelete ' . b + endif + endfor + " and reopen the list + call BufferList() +endfunction + function! BufferListGetSelectedBuffer() " this is our string containing the buffer numbers in " the order of the list (separated by ':') From 9d6d580876fff0da6c354a6454aa3668b6929472 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 18 Apr 2013 12:37:06 +0200 Subject: [PATCH 03/22] Remove an unnecessary variable --- plugin/bufferlist.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 0ec24ec..8016c86 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -279,10 +279,8 @@ function! BufferListDeleteHiddenBuffers() " kill the buffer list bwipeout " close any buffer that are loaded and not visible - let l:tally = 0 for b in range(1, bufnr('$')) if buflisted(b) && !has_key(l:visible, b) - let l:tally += 1 exe ':bdelete ' . b endif endfor From 5eeaf8edbe37c951178c21d4230656f000d0adbf Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 19 Apr 2013 05:42:34 +0200 Subject: [PATCH 04/22] Fix window openning despite of how if it is closed --- plugin/bufferlist.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 8016c86..9a5d254 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -48,8 +48,13 @@ endif function! BufferList() " if we get called and the list is open --> close it if bufexists(bufnr("__BUFFERLIST__")) - exec ':' . bufnr("__BUFFERLIST__") . 'bwipeout' - return + let l:buflistnr = bufnr("__BUFFERLIST__") + let l:buflistwindow = bufwinnr(l:buflistnr) + exec ':' . l:buflistnr . 'bwipeout' + " if the list wasn't open, just the buffer existed, proceed with opening + if l:buflistwindow != -1 + return + endif endif let l:bufcount = bufnr('$') From 9de9ff8e7ce1e99974625ecdda019aa18165946e Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sat, 27 Apr 2013 17:51:34 +0200 Subject: [PATCH 05/22] Add the 'tab friends' feature --- README.md | 20 ++++++++++++++++++++ plugin/bufferlist.vim | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 876accf..261dfc7 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ VIM bufferlist This is an implementation of [EMACS bufferlist](http://github.com/rockpiper/emacs-bufferlist) for [VIM](http://www.vim.org). +This fork contains additional modifications by Szymon Wrozynski. Basically, now it can: + +* show unnamed buffers +* delete hidden buffers +* show tab-related buffers only + About ----- @@ -21,6 +27,19 @@ To delete a buffer from the list (i.e. close the file) press `d`. To delete all hidden buffers (the ones not visible in any tab) press `D`. +If you want to see buffers related with the current tab only, press `t`.
+ +To switch back to all buffers view, press `t` again. This feature, +called internally *tab friends*, can be turned off by setting +`g:BufferListShowTabFriends = 0`. If you set `g:BufferListShowTabFriends = 2` +tab friends are turned on and visible by default. + + +Tab Friends +----------- + + + Usage ----- @@ -34,6 +53,7 @@ like this in your `~/.vimrc`: ### Optional let g:BufferListShowUnnamed = 1 + let g:BufferListShowTabFriends = 2 let g:BufferListWidth = 25 let g:BufferListMaxWidth = 50 hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 9a5d254..7944fe2 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -44,6 +44,17 @@ if !exists('g:BufferListShowUnnamed') let g:BufferListShowUnnamed = 0 endif +if !exists('g:BufferListShowTabFriends') + let g:BufferListShowTabFriends = 1 +endif + +if g:BufferListShowTabFriends + au BufEnter * call BufferListAddTabFriend() +endif + +let s:tabfriendstoggle = (g:BufferListShowTabFriends == 2) +end + " toggled the buffer list on/off function! BufferList() " if we get called and the list is open --> close it @@ -53,7 +64,7 @@ function! BufferList() exec ':' . l:buflistnr . 'bwipeout' " if the list wasn't open, just the buffer existed, proceed with opening if l:buflistwindow != -1 - return + return endif endif @@ -70,7 +81,11 @@ function! BufferList() let l:bufname = bufname(l:i) if g:BufferListShowUnnamed && !strlen(l:bufname) - let l:bufname = '[' . l:i . '*No Name]' + let l:bufname = '[' . l:i . '*No Name]' + endif + + if s:tabfriendstoggle && !exists('t:BufferListTabFriends[' . l:i . ']') + continue endif if strlen(l:bufname) @@ -163,6 +178,11 @@ function! BufferList() map k :call BufferListMove("up") map d :call BufferListDeleteBuffer() map D :call BufferListDeleteHiddenBuffers() + + if g:BufferListShowTabFriends + map t :call BufferListToggleTabFriends() + endif + map :call BufferListMove("up") map :call BufferListMove("down") map @@ -285,7 +305,7 @@ function! BufferListDeleteHiddenBuffers() bwipeout " close any buffer that are loaded and not visible for b in range(1, bufnr('$')) - if buflisted(b) && !has_key(l:visible, b) + if buflisted(b) && !has_key(l:visible, b) && !getbufvar(l:visible, '&modified') exe ':bdelete ' . b endif endfor @@ -309,3 +329,20 @@ function! BufferListGetSelectedBuffer() return l:str endfunction +function! BufferListAddTabFriend() + if !exists('t:BufferListTabFriends') + let t:BufferListTabFriends = {} + endif + + let l:current = bufnr('%') + + if getbufvar(l:current, '&modifiable') && getbufvar(l:current, '&buflisted') && l:current != bufnr("__BUFFERLIST__") + let t:BufferListTabFriends[l:current] = 1 + endif +endfunction + +function! BufferListToggleTabFriends() + let s:tabfriendstoggle = !s:tabfriendstoggle + bwipeout + call BufferList() +endfunction From aff3df5ea65094f2875b3ecbb869e415159fe0a1 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sat, 27 Apr 2013 17:59:54 +0200 Subject: [PATCH 06/22] Remove the unnecessary 'end' keyword --- plugin/bufferlist.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 7944fe2..f737ff9 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -53,7 +53,6 @@ if g:BufferListShowTabFriends endif let s:tabfriendstoggle = (g:BufferListShowTabFriends == 2) -end " toggled the buffer list on/off function! BufferList() From 591e1ae51e41870c5fd55468a9308d0e90aa37d4 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sat, 27 Apr 2013 18:12:56 +0200 Subject: [PATCH 07/22] Remove empty header --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 261dfc7..18ed8e2 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,6 @@ called internally *tab friends*, can be turned off by setting tab friends are turned on and visible by default. -Tab Friends ------------ - - - Usage ----- From 801317bb38db61405a2884bc10a1dce726886af6 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sat, 27 Apr 2013 21:40:55 +0200 Subject: [PATCH 08/22] Update README --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 18ed8e2..90e9eb0 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ This fork contains additional modifications by Szymon Wrozynski. Basically, now * delete hidden buffers * show tab-related buffers only +Please, don't forget to star the repository if you like (and use) the plugin. +This will let me know how many users it has and then how to proceed with further +development :). + About ----- @@ -27,13 +31,13 @@ To delete a buffer from the list (i.e. close the file) press `d`. To delete all hidden buffers (the ones not visible in any tab) press `D`. -If you want to see buffers related with the current tab only, press `t`.
- -To switch back to all buffers view, press `t` again. This feature, -called internally *tab friends*, can be turned off by setting -`g:BufferListShowTabFriends = 0`. If you set `g:BufferListShowTabFriends = 2` -tab friends are turned on and visible by default. - +If you want to see buffers related with the current tab only, press `t`. + +*Related* means buffers seen in that tab at least once. To switch back to all +buffers view, press `t` again. This feature, called internally *tab friends*, +can be turned off by setting `g:BufferListShowTabFriends = 0`. +If you set `g:BufferListShowTabFriends = 2` tab friends are turned on and +visible by default. Of course, the `t` key can toggle the view all the time. Usage ----- From 7fc01740f7e8f4df7a503b13ec90f9a3dcedc5f6 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sun, 28 Apr 2013 03:20:52 +0200 Subject: [PATCH 09/22] Add the tab friends detaching Also add minor fixes while deleting unsaved buffers and introduce the 'BufferList' command. The command is now preferred to the function call. --- README.md | 7 +++++-- plugin/bufferlist.vim | 45 ++++++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 90e9eb0..c049006 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ modified are marked with `+`. To delete a buffer from the list (i.e. close the file) press `d`. -To delete all hidden buffers (the ones not visible in any tab) press `D`. +To delete all hidden buffers (the ones not visible in any tab) press `D` (uppercase). If you want to see buffers related with the current tab only, press `t`. @@ -39,6 +39,9 @@ can be turned off by setting `g:BufferListShowTabFriends = 0`. If you set `g:BufferListShowTabFriends = 2` tab friends are turned on and visible by default. Of course, the `t` key can toggle the view all the time. +You can also detach a tab friend buffer from the current tab. We would say +to make it a stranger ;). To perform that press `T` (uppercase). + Usage ----- @@ -47,7 +50,7 @@ like this in your `~/.vimrc`: ### Needed - map :call BufferList() + map :BufferList ### Optional diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index f737ff9..9fce8fe 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -18,7 +18,7 @@ "= your ~/.vimrc: = "= = "= NEEDED: = -"= map :call BufferList() = +"= map :BufferList = "= OPTIONAL: = "= let g:BufferListShowUnnamed = 1 = "= let g:BufferListWidth = 25 = @@ -52,10 +52,14 @@ if g:BufferListShowTabFriends au BufEnter * call BufferListAddTabFriend() endif -let s:tabfriendstoggle = (g:BufferListShowTabFriends == 2) +command! -nargs=0 BufferList :call BufferList(0) " toggled the buffer list on/off -function! BufferList() +function! BufferList(internal) + if !a:internal + let s:tabfriendstoggle = (g:BufferListShowTabFriends == 2) + endif + " if we get called and the list is open --> close it if bufexists(bufnr("__BUFFERLIST__")) let l:buflistnr = bufnr("__BUFFERLIST__") @@ -87,10 +91,7 @@ function! BufferList() continue endif - if strlen(l:bufname) - \&& getbufvar(l:i, '&modifiable') - \&& getbufvar(l:i, '&buflisted') - + if strlen(l:bufname) && getbufvar(l:i, '&modifiable') && getbufvar(l:i, '&buflisted') " adapt width and/or buffer name if l:width < (strlen(l:bufname) + 5) if strlen(l:bufname) + 5 < g:BufferListMaxWidth @@ -180,6 +181,7 @@ function! BufferList() if g:BufferListShowTabFriends map t :call BufferListToggleTabFriends() + map T :call BufferListDetachTabFriend() endif map :call BufferListMove("up") @@ -282,12 +284,14 @@ endfunction function! BufferListDeleteBuffer() " get the selected buffer let l:str = BufferListGetSelectedBuffer() - " kill the buffer list - bwipeout - " delete the selected buffer - exec ":bdelete " . l:str - " and reopen the list - call BufferList() + if !getbufvar(str2nr(l:str), '&modified') + " kill the buffer list + bwipeout + " delete the selected buffer + exec ":bdelete " . l:str + " and reopen the list + call BufferList(1) + endif endfunction " deletes all hidden buffers @@ -304,12 +308,12 @@ function! BufferListDeleteHiddenBuffers() bwipeout " close any buffer that are loaded and not visible for b in range(1, bufnr('$')) - if buflisted(b) && !has_key(l:visible, b) && !getbufvar(l:visible, '&modified') + if buflisted(b) && !has_key(l:visible, b) && !getbufvar(b, '&modified') exe ':bdelete ' . b endif endfor " and reopen the list - call BufferList() + call BufferList(1) endfunction function! BufferListGetSelectedBuffer() @@ -343,5 +347,14 @@ endfunction function! BufferListToggleTabFriends() let s:tabfriendstoggle = !s:tabfriendstoggle bwipeout - call BufferList() + call BufferList(1) +endfunction + +function! BufferListDetachTabFriend() + let l:str = BufferListGetSelectedBuffer() + if exists('t:BufferListTabFriends[' . l:str . ']') && (bufwinnr(str2nr(l:str)) == -1) + bwipeout + call remove(t:BufferListTabFriends, l:str) + call BufferList(1) + endif endfunction From a725fb4ce725103c8fe551fca99c67983df02e3e Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Sun, 28 Apr 2013 12:06:21 +0200 Subject: [PATCH 10/22] Allow range in the command --- plugin/bufferlist.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 9fce8fe..06bfc7e 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -52,7 +52,7 @@ if g:BufferListShowTabFriends au BufEnter * call BufferListAddTabFriend() endif -command! -nargs=0 BufferList :call BufferList(0) +command! -nargs=0 -range BufferList :call BufferList(0) " toggled the buffer list on/off function! BufferList(internal) From 0f2f219566e6d77383bc6dc630acfc4a8ac2a2dc Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Mon, 29 Apr 2013 22:24:44 +0200 Subject: [PATCH 11/22] Add example to the comment --- plugin/bufferlist.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 06bfc7e..0afd125 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -21,6 +21,7 @@ "= map :BufferList = "= OPTIONAL: = "= let g:BufferListShowUnnamed = 1 = +"= let g:BufferListShowTabFriends = 2 = "= let g:BufferListWidth = 25 = "= let g:BufferListMaxWidth = 50 = "= hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold = From 9e00dc608449e58dd1ff4ed5bafc4798a0a39d89 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Tue, 30 Apr 2013 00:27:41 +0200 Subject: [PATCH 12/22] Add new option for showing unnamed buffers --- README.md | 7 +++++++ plugin/bufferlist.vim | 34 ++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index c049006..97909f5 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,13 @@ one expects. Buffers that are visible (in any window) are marked with `*`, ones that are modified are marked with `+`. +You can adjust the displaying of unnamed buffers. If you set +`g:BufferListShowUnnamed = 1` then unnamed buffers will be shown on the list +any time. However, if you set this value to `2` (default), unnamed buffers will +be displayed only if they are modified or just visible on the screen. + +Of course you can hide unnamed buffers permanently by `g:BufferListShowUnnamed = 0`. + To delete a buffer from the list (i.e. close the file) press `d`. To delete all hidden buffers (the ones not visible in any tab) press `D` (uppercase). diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 0afd125..793531e 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -42,7 +42,7 @@ if !exists('g:BufferListMaxWidth') endif if !exists('g:BufferListShowUnnamed') - let g:BufferListShowUnnamed = 0 + let g:BufferListShowUnnamed = 2 endif if !exists('g:BufferListShowTabFriends') @@ -82,14 +82,16 @@ function! BufferList(internal) " iterate through the buffers let l:i = 0 | while l:i <= l:bufcount | let l:i = l:i + 1 + if s:tabfriendstoggle && !exists('t:BufferListTabFriends[' . l:i . ']') + continue + endif + let l:bufname = bufname(l:i) if g:BufferListShowUnnamed && !strlen(l:bufname) - let l:bufname = '[' . l:i . '*No Name]' - endif - - if s:tabfriendstoggle && !exists('t:BufferListTabFriends[' . l:i . ']') - continue + if !((g:BufferListShowUnnamed == 2) && !getbufvar(l:i, '&modified')) || (bufwinnr(l:i) != -1) + let l:bufname = '[' . l:i . '*No Name]' + endif endif if strlen(l:bufname) && getbufvar(l:i, '&modifiable') && getbufvar(l:i, '&buflisted') @@ -99,20 +101,20 @@ function! BufferList(internal) let l:width = strlen(l:bufname) + 5 else let l:width = g:BufferListMaxWidth - let l:bufname = '...' . strpart(l:bufname, strlen(l:bufname) - g:BufferListMaxWidth + 8) + let l:bufname = '…' . strpart(l:bufname, strlen(l:bufname) - g:BufferListMaxWidth + 6) endif endif if bufwinnr(l:i) != -1 - let l:bufname = l:bufname . '*' + let l:bufname .= '*' endif if getbufvar(l:i, '&modified') - let l:bufname = l:bufname . '+' + let l:bufname .= '+' endif " count displayed buffers - let l:displayedbufs = l:displayedbufs + 1 + let l:displayedbufs += 1 " remember buffer numbers - let l:bufnumbers = l:bufnumbers . l:i . ':' + let l:bufnumbers .= l:i . ':' " remember the buffer that was active BEFORE showing the list if l:activebuf == l:i let l:activebufline = l:displayedbufs @@ -120,10 +122,10 @@ function! BufferList(internal) " fill the name with spaces --> gives a nice selection bar " use MAX width here, because the width may change inside of this 'for' loop while strlen(l:bufname) < g:BufferListMaxWidth - let l:bufname = l:bufname . ' ' + let l:bufname .= ' ' endwhile " add the name to the list - let l:buflist = l:buflist . ' ' .l:bufname . "\n" + let l:buflist .= ' ' . l:bufname . "\n" endif endwhile @@ -159,8 +161,8 @@ function! BufferList(internal) " input the buffer list, delete the trailing newline, & fill with blank lines put! =l:buflist " is there any way to NOT delete into a register? bummer... - "norm Gdd$ - norm GkJ + "normal! Gdd$ + normal! GkJ while winheight(0) > line(".") put =l:fill endwhile @@ -168,7 +170,7 @@ function! BufferList(internal) let l:i = 0 | while l:i < winheight(0) | let l:i = l:i + 1 put! =l:fill endwhile - norm 0 + normal! 0 endif setlocal nomodifiable From 4d6c998f6ed1ac070d4bc19139e71f101d09b1b9 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Tue, 30 Apr 2013 04:21:41 +0200 Subject: [PATCH 13/22] Refactor some code --- plugin/bufferlist.vim | 89 ++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 793531e..deb1d24 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -2,6 +2,9 @@ "= Copyright(c) 2005, Robert Lillack = "= Redistribution in any form with or without modification permitted. = "= = +"= Modifications and further improvements = +"= (c) 2013 Szymon Wrozynski , https://github.com/szw = +"= = "= INFORMATION ================================================================= "= Upon keypress this script display a nice list of buffers on the left, which = "= can be selected with mouse or keyboard. As soon as a buffer is selected = @@ -50,13 +53,13 @@ if !exists('g:BufferListShowTabFriends') endif if g:BufferListShowTabFriends - au BufEnter * call BufferListAddTabFriend() + au BufEnter * call BufferListAddTabFriend() endif -command! -nargs=0 -range BufferList :call BufferList(0) +command! -nargs=0 -range BufferList :call BufferList(0) " toggled the buffer list on/off -function! BufferList(internal) +function! BufferList(internal) if !a:internal let s:tabfriendstoggle = (g:BufferListShowTabFriends == 2) endif @@ -81,7 +84,7 @@ function! BufferList(internal) let l:width = g:BufferListWidth " iterate through the buffers - let l:i = 0 | while l:i <= l:bufcount | let l:i = l:i + 1 + let l:i = 0 | while l:i <= l:bufcount | let l:i += 1 if s:tabfriendstoggle && !exists('t:BufferListTabFriends[' . l:i . ']') continue endif @@ -132,7 +135,7 @@ function! BufferList(internal) " generate a variable to fill the buffer afterwards " (we need this for "full window" color :) let l:fill = "\n" - let l:i = 0 | while l:i < l:width | let l:i = l:i + 1 + let l:i = 0 | while l:i < l:width | let l:i += 1 let l:fill = ' ' . l:fill endwhile @@ -167,7 +170,7 @@ function! BufferList(internal) put =l:fill endwhile else - let l:i = 0 | while l:i < winheight(0) | let l:i = l:i + 1 + let l:i = 0 | while l:i < winheight(0) | let l:i += 1 put! =l:fill endwhile normal! 0 @@ -175,24 +178,24 @@ function! BufferList(internal) setlocal nomodifiable " set up the keymap - noremap :call LoadBuffer() + noremap :call LoadBuffer() map q :bwipeout - map j :call BufferListMove("down") - map k :call BufferListMove("up") - map d :call BufferListDeleteBuffer() - map D :call BufferListDeleteHiddenBuffers() + map j :call BufferListMove("down") + map k :call BufferListMove("up") + map d :call BufferListDeleteBuffer() + map D :call BufferListDeleteHiddenBuffers() if g:BufferListShowTabFriends - map t :call BufferListToggleTabFriends() - map T :call BufferListDetachTabFriend() + map t :call BufferListToggleTabFriends() + map T :call BufferListDetachTabFriend() endif - map :call BufferListMove("up") - map :call BufferListMove("down") + map :call BufferListMove("up") + map :call BufferListMove("down") map - map :call BufferListMove("mouse") - map <2-LeftMouse> :call BufferListMove("mouse") - \:call LoadBuffer() + map :call BufferListMove("mouse") + map <2-LeftMouse> :call BufferListMove("mouse") + \:call LoadBuffer() map j map k map h @@ -205,8 +208,8 @@ function! BufferList(internal) map A map o map O - map :call BufferListMove(1) - map :call BufferListMove(line("$")) + map :call BufferListMove(1) + map :call BufferListMove(line("$")) " make the buffer count & the buffer numbers available " for our other functions @@ -214,13 +217,13 @@ function! BufferList(internal) let b:bufcount = l:displayedbufs " go to the correct line - call BufferListMove(l:activebufline) + call BufferListMove(l:activebufline) endfunction " move the selection bar of the list: " where can be "up"/"down"/"mouse" or " a line number -function! BufferListMove(where) +function! BufferListMove(where) if b:bufcount < 1 return endif @@ -234,7 +237,7 @@ function! BufferListMove(where) " and go back to the original location for now if a:where == "mouse" let l:newpos = line(".") - call BufferListGoto(b:lastline) + call BufferListGoto(b:lastline) endif " exchange the first char (>) with a space @@ -242,13 +245,13 @@ function! BufferListMove(where) " go where the user want's us to go if a:where == "up" - call BufferListGoto(line(".")-1) + call BufferListGoto(line(".")-1) elseif a:where == "down" - call BufferListGoto(line(".")+1) + call BufferListGoto(line(".")+1) elseif a:where == "mouse" - call BufferListGoto(l:newpos) + call BufferListGoto(l:newpos) else - call BufferListGoto(a:where) + call BufferListGoto(a:where) endif " and mark this line with a > @@ -262,7 +265,7 @@ function! BufferListMove(where) endfunction " tries to set the cursor to a line of the buffer list -function! BufferListGoto(line) +function! BufferListGoto(line) if b:bufcount < 1 | return | endif if a:line < 1 call cursor(1, 1) @@ -274,9 +277,9 @@ function! BufferListGoto(line) endfunction " loads the selected buffer -function! LoadBuffer() +function! LoadBuffer() " get the selected buffer - let l:str = BufferListGetSelectedBuffer() + let l:str = BufferListGetSelectedBuffer() " kill the buffer list bwipeout " ...and switch to the buffer number @@ -284,22 +287,22 @@ function! LoadBuffer() endfunction " deletes the selected buffer -function! BufferListDeleteBuffer() +function! BufferListDeleteBuffer() " get the selected buffer - let l:str = BufferListGetSelectedBuffer() + let l:str = BufferListGetSelectedBuffer() if !getbufvar(str2nr(l:str), '&modified') " kill the buffer list bwipeout " delete the selected buffer exec ":bdelete " . l:str " and reopen the list - call BufferList(1) + call BufferList(1) endif endfunction " deletes all hidden buffers " taken from: http://stackoverflow.com/a/3180886 -function! BufferListDeleteHiddenBuffers() +function! BufferListDeleteHiddenBuffers() " figure out which buffers are visible in any tab let l:visible = {} for t in range(1, tabpagenr('$')) @@ -316,16 +319,16 @@ function! BufferListDeleteHiddenBuffers() endif endfor " and reopen the list - call BufferList(1) + call BufferList(1) endfunction -function! BufferListGetSelectedBuffer() +function! BufferListGetSelectedBuffer() " this is our string containing the buffer numbers in " the order of the list (separated by ':') let l:str = b:bufnumbers " remove all numbers BEFORE the one we want - let l:i = 1 | while l:i < line(".") | let l:i = l:i + 1 + let l:i = 1 | while l:i < line(".") | let l:i += 1 let l:str = strpart(l:str, stridx(l:str, ':') + 1) endwhile @@ -335,7 +338,7 @@ function! BufferListGetSelectedBuffer() return l:str endfunction -function! BufferListAddTabFriend() +function! BufferListAddTabFriend() if !exists('t:BufferListTabFriends') let t:BufferListTabFriends = {} endif @@ -347,17 +350,17 @@ function! BufferListAddTabFriend() endif endfunction -function! BufferListToggleTabFriends() +function! BufferListToggleTabFriends() let s:tabfriendstoggle = !s:tabfriendstoggle bwipeout - call BufferList(1) + call BufferList(1) endfunction -function! BufferListDetachTabFriend() - let l:str = BufferListGetSelectedBuffer() +function! BufferListDetachTabFriend() + let l:str = BufferListGetSelectedBuffer() if exists('t:BufferListTabFriends[' . l:str . ']') && (bufwinnr(str2nr(l:str)) == -1) bwipeout call remove(t:BufferListTabFriends, l:str) - call BufferList(1) + call BufferList(1) endif endfunction From 52c808f150dee12af299ae5da10b7d1fd5d36a81 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 2 May 2013 02:29:57 +0200 Subject: [PATCH 14/22] Add closing orphaned buffers --- README.md | 22 +++++++++++++-------- plugin/bufferlist.vim | 45 +++++++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 97909f5..4800578 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,21 @@ To delete a buffer from the list (i.e. close the file) press `d`. To delete all hidden buffers (the ones not visible in any tab) press `D` (uppercase). -If you want to see buffers related with the current tab only, press `t`. +If you want to toggle between all buffers view and those related with the current +tab only, press `a`. -*Related* means buffers seen in that tab at least once. To switch back to all -buffers view, press `t` again. This feature, called internally *tab friends*, -can be turned off by setting `g:BufferListShowTabFriends = 0`. -If you set `g:BufferListShowTabFriends = 2` tab friends are turned on and -visible by default. Of course, the `t` key can toggle the view all the time. +*Related* means buffers seen in that tab at least once. This feature, called internally +*tab friends*, can be turned off by setting `g:BufferListShowTabFriends = 0`. +To see all buffers by default switch `g:BufferListShowTabFriends = 1`. +If you set `g:BufferListShowTabFriends = 2` (default) tab friends are turned on and +visible by default. Of course, the `a` key can toggle the view all the time. You can also detach a tab friend buffer from the current tab. We would say -to make it a stranger ;). To perform that press `T` (uppercase). +to make it a foreign one ;). To perform that press `t`. + +You can also close all detached (foreign) buffers, if you press uppercase letter `T`. +This can be useful to clean up "orphaned" buffers, if you just have closed the tab +you were working with. Usage ----- @@ -62,7 +67,7 @@ like this in your `~/.vimrc`: ### Optional let g:BufferListShowUnnamed = 1 - let g:BufferListShowTabFriends = 2 + let g:BufferListShowTabFriends = 1 let g:BufferListWidth = 25 let g:BufferListMaxWidth = 50 hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold @@ -74,3 +79,4 @@ License Copyright(c) 2005, Robert Lillack Redistribution in any form with or without modification permitted. +Modifications (c) 2013, Szymon Wrozynski diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index deb1d24..32364b1 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -1,4 +1,4 @@ -"=== VIM BUFFER LIST SCRIPT 1.3 ================================================ +"=== VIM BUFFER LIST SCRIPT 1.4 ================================================ "= Copyright(c) 2005, Robert Lillack = "= Redistribution in any form with or without modification permitted. = "= = @@ -24,7 +24,7 @@ "= map :BufferList = "= OPTIONAL: = "= let g:BufferListShowUnnamed = 1 = -"= let g:BufferListShowTabFriends = 2 = +"= let g:BufferListShowTabFriends = 1 = "= let g:BufferListWidth = 25 = "= let g:BufferListMaxWidth = 50 = "= hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold = @@ -49,7 +49,7 @@ if !exists('g:BufferListShowUnnamed') endif if !exists('g:BufferListShowTabFriends') - let g:BufferListShowTabFriends = 1 + let g:BufferListShowTabFriends = 2 endif if g:BufferListShowTabFriends @@ -184,12 +184,6 @@ function! BufferList(internal) map k :call BufferListMove("up") map d :call BufferListDeleteBuffer() map D :call BufferListDeleteHiddenBuffers() - - if g:BufferListShowTabFriends - map t :call BufferListToggleTabFriends() - map T :call BufferListDetachTabFriend() - endif - map :call BufferListMove("up") map :call BufferListMove("down") map @@ -211,6 +205,12 @@ function! BufferList(internal) map :call BufferListMove(1) map :call BufferListMove(line("$")) + if g:BufferListShowTabFriends + map a :call BufferListToggleTabFriends() + map t :call BufferListDetachTabFriend() + map T :call BufferListDeleteForeignBuffers() + endif + " make the buffer count & the buffer numbers available " for our other functions let b:bufnumbers = l:bufnumbers @@ -300,25 +300,36 @@ function! BufferListDeleteBuffer() endif endfunction +function! BufferListKeepBuffersForKeys(a:dictionary) + for b in range(1, bufnr('$')) + if buflisted(b) && !has_key(a:visible, b) && !getbufvar(b, '&modified') + exe ':bdelete ' . b + endif + endfor +endfunction + " deletes all hidden buffers " taken from: http://stackoverflow.com/a/3180886 function! BufferListDeleteHiddenBuffers() - " figure out which buffers are visible in any tab let l:visible = {} for t in range(1, tabpagenr('$')) for b in tabpagebuflist(t) let l:visible[b] = 1 endfor endfor - " kill the buffer list bwipeout - " close any buffer that are loaded and not visible - for b in range(1, bufnr('$')) - if buflisted(b) && !has_key(l:visible, b) && !getbufvar(b, '&modified') - exe ':bdelete ' . b - endif + call BufferListKeepBuffersForKeys(l:visible) + call BufferList(1) +endfunction + +" deletes all foreign (not tab friend) buffers +function! BufferListDeleteForeignBuffers() + let l:friends = {} + for t in range(1, tabpagenr('$')) + silent! call extend(l:friends, gettabvar(t, 'BufferListTabFriends')) endfor - " and reopen the list + bwipeout + call BufferListKeepBuffersForKeys(l:friends) call BufferList(1) endfunction From 0713a2a28042515c0c534eda3d1afeaf7b573902 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 2 May 2013 02:46:49 +0200 Subject: [PATCH 15/22] Fix variable name --- plugin/bufferlist.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 32364b1..d3f5752 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -300,9 +300,9 @@ function! BufferListDeleteBuffer() endif endfunction -function! BufferListKeepBuffersForKeys(a:dictionary) +function! BufferListKeepBuffersForKeys(a:dict) for b in range(1, bufnr('$')) - if buflisted(b) && !has_key(a:visible, b) && !getbufvar(b, '&modified') + if buflisted(b) && !has_key(a:dict, b) && !getbufvar(b, '&modified') exe ':bdelete ' . b endif endfor From 9b075ca3b2db5ac9454cbb88241d238112597ced Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 2 May 2013 02:50:47 +0200 Subject: [PATCH 16/22] Fix argument name --- plugin/bufferlist.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index d3f5752..9badb3c 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -300,7 +300,7 @@ function! BufferListDeleteBuffer() endif endfunction -function! BufferListKeepBuffersForKeys(a:dict) +function! BufferListKeepBuffersForKeys(dict) for b in range(1, bufnr('$')) if buflisted(b) && !has_key(a:dict, b) && !getbufvar(b, '&modified') exe ':bdelete ' . b From 6fcfca8de29d0f6847cba7a575271083f1ee8b7e Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Thu, 2 May 2013 12:21:50 +0200 Subject: [PATCH 17/22] Allow to detach the selected buffer from the tab --- plugin/bufferlist.vim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index 9badb3c..b9fb61f 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -369,8 +369,19 @@ endfunction function! BufferListDetachTabFriend() let l:str = BufferListGetSelectedBuffer() - if exists('t:BufferListTabFriends[' . l:str . ']') && (bufwinnr(str2nr(l:str)) == -1) - bwipeout + if exists('t:BufferListTabFriends[' . l:str . ']') + if bufwinnr(str2nr(l:str)) != -1 + call BufferListMove("down") + if BufferListGetSelectedBuffer() == l:str + call BufferListMove("up") + if BufferListGetSelectedBuffer() == l:str + return + endif + endif + call LoadBuffer() + else + bwipeout + endif call remove(t:BufferListTabFriends, l:str) call BufferList(1) endif From a59eb4403444fbce07cb5e2c440a2918dacb17f4 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 3 May 2013 15:03:28 +0200 Subject: [PATCH 18/22] Improve key bindings and allow open in splits --- README.md | 54 +++++++++++++++++++++++++++++++++++++++---- plugin/bufferlist.vim | 18 +++++++++++---- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4800578..02ac1bf 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ This fork contains additional modifications by Szymon Wrozynski. Basically, now * show unnamed buffers * delete hidden buffers -* show tab-related buffers only +* work with tab-related buffers +* open buffers in splits and tabs Please, don't forget to star the repository if you like (and use) the plugin. This will let me know how many users it has and then how to proceed with further @@ -18,7 +19,7 @@ About Upon keypress this script display a nice list of buffers on the left, which can be selected with mouse or keyboard. As soon as a buffer is selected -(Return, double click) the list disappears. +(`Return` (or `s`, `v`, `t`), double click) the list disappears. The selection can be cancelled with the same key that is configured to open the list or by pressing `q`. Movement key and mouse (wheel) should work as @@ -48,12 +49,57 @@ If you set `g:BufferListShowTabFriends = 2` (default) tab friends are turned on visible by default. Of course, the `a` key can toggle the view all the time. You can also detach a tab friend buffer from the current tab. We would say -to make it a foreign one ;). To perform that press `t`. +to make it a foreign one ;). To perform that press `f` (a good mnemonic could be *forget*) -You can also close all detached (foreign) buffers, if you press uppercase letter `T`. +You can also close all detached (foreign) buffers, if you press uppercase letter `F`. This can be useful to clean up "orphaned" buffers, if you just have closed the tab you were working with. +### Keys summary ### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyAction
ReturnOpens the selected buffer
tOpens the selected buffer in a new tab
sOpens the selected buffer in a new horizontal split
vOpens the selected buffer in a new vertical split
dDeletes the selected buffer (closes it)
DDeletes (closes) all hidden (not displayed in any tab) buffers
fForgets the current buffer (make it a *foreign* (unrelated) to the current tab)
FDeletes (closes) all forgotten buffers (unrelated with any tab)
q or F2Closes the list
+ Usage ----- diff --git a/plugin/bufferlist.vim b/plugin/bufferlist.vim index b9fb61f..ff14ae9 100644 --- a/plugin/bufferlist.vim +++ b/plugin/bufferlist.vim @@ -1,4 +1,4 @@ -"=== VIM BUFFER LIST SCRIPT 1.4 ================================================ +"=== VIM BUFFER LIST SCRIPT 1.5 ================================================ "= Copyright(c) 2005, Robert Lillack = "= Redistribution in any form with or without modification permitted. = "= = @@ -8,7 +8,7 @@ "= INFORMATION ================================================================= "= Upon keypress this script display a nice list of buffers on the left, which = "= can be selected with mouse or keyboard. As soon as a buffer is selected = -"= (Return, double click) the list disappears. = +"= ('Return' (or 's', 'v', 't'), double click) the list disappears. = "= The selection can be cancelled with the same key that is configured to open = "= the list or by pressing 'q'. Movement key and mouse (wheel) should work as = "= one expects. = @@ -179,6 +179,9 @@ function! BufferList(internal) " set up the keymap noremap :call LoadBuffer() + noremap v :call LoadBuffer("vs") + noremap s :call LoadBuffer("sp") + noremap t :call LoadBuffer("tabnew") map q :bwipeout map j :call BufferListMove("down") map k :call BufferListMove("up") @@ -207,8 +210,8 @@ function! BufferList(internal) if g:BufferListShowTabFriends map a :call BufferListToggleTabFriends() - map t :call BufferListDetachTabFriend() - map T :call BufferListDeleteForeignBuffers() + map f :call BufferListDetachTabFriend() + map F :call BufferListDeleteForeignBuffers() endif " make the buffer count & the buffer numbers available @@ -277,11 +280,16 @@ function! BufferListGoto(line) endfunction " loads the selected buffer -function! LoadBuffer() +function! LoadBuffer(...) " get the selected buffer let l:str = BufferListGetSelectedBuffer() " kill the buffer list bwipeout + + if !empty(a:000) + exec ":" . a:1 + endif + " ...and switch to the buffer number exec ":b " . l:str endfunction From 6196ab3e993556833216018d9d0360007a150c0e Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 3 May 2013 15:06:14 +0200 Subject: [PATCH 19/22] Fix formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02ac1bf..3dd1483 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ you were working with. f -Forgets the current buffer (make it a *foreign* (unrelated) to the current tab) +Forgets the current buffer (make it a foreign (unrelated) to the current tab) F From 0b534a21fb1fc606a41b90049f24de4b8410ff04 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 3 May 2013 15:56:40 +0200 Subject: [PATCH 20/22] Add deprecation info --- README.md | 120 ++---------------------------------------------------- 1 file changed, 4 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index 3dd1483..2b3e10e 100644 --- a/README.md +++ b/README.md @@ -1,123 +1,11 @@ VIM bufferlist ============== -This is an implementation of [EMACS bufferlist](http://github.com/rockpiper/emacs-bufferlist) for [VIM](http://www.vim.org). +Deprecation warning +------------------- -This fork contains additional modifications by Szymon Wrozynski. Basically, now it can: - -* show unnamed buffers -* delete hidden buffers -* work with tab-related buffers -* open buffers in splits and tabs - -Please, don't forget to star the repository if you like (and use) the plugin. -This will let me know how many users it has and then how to proceed with further -development :). - -About ------ - -Upon keypress this script display a nice list of buffers on the left, which -can be selected with mouse or keyboard. As soon as a buffer is selected -(`Return` (or `s`, `v`, `t`), double click) the list disappears. - -The selection can be cancelled with the same key that is configured to open -the list or by pressing `q`. Movement key and mouse (wheel) should work as -one expects. - -Buffers that are visible (in any window) are marked with `*`, ones that are -modified are marked with `+`. - -You can adjust the displaying of unnamed buffers. If you set -`g:BufferListShowUnnamed = 1` then unnamed buffers will be shown on the list -any time. However, if you set this value to `2` (default), unnamed buffers will -be displayed only if they are modified or just visible on the screen. - -Of course you can hide unnamed buffers permanently by `g:BufferListShowUnnamed = 0`. - -To delete a buffer from the list (i.e. close the file) press `d`. - -To delete all hidden buffers (the ones not visible in any tab) press `D` (uppercase). - -If you want to toggle between all buffers view and those related with the current -tab only, press `a`. - -*Related* means buffers seen in that tab at least once. This feature, called internally -*tab friends*, can be turned off by setting `g:BufferListShowTabFriends = 0`. -To see all buffers by default switch `g:BufferListShowTabFriends = 1`. -If you set `g:BufferListShowTabFriends = 2` (default) tab friends are turned on and -visible by default. Of course, the `a` key can toggle the view all the time. - -You can also detach a tab friend buffer from the current tab. We would say -to make it a foreign one ;). To perform that press `f` (a good mnemonic could be *forget*) - -You can also close all detached (foreign) buffers, if you press uppercase letter `F`. -This can be useful to clean up "orphaned" buffers, if you just have closed the tab -you were working with. - -### Keys summary ### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyAction
ReturnOpens the selected buffer
tOpens the selected buffer in a new tab
sOpens the selected buffer in a new horizontal split
vOpens the selected buffer in a new vertical split
dDeletes the selected buffer (closes it)
DDeletes (closes) all hidden (not displayed in any tab) buffers
fForgets the current buffer (make it a foreign (unrelated) to the current tab)
FDeletes (closes) all forgotten buffers (unrelated with any tab)
q or F2Closes the list
- -Usage ------ - -Put bufferlist.vim file into your `~/.vim/plugin` directory and set it up -like this in your `~/.vimrc`: - -### Needed - - map :BufferList - -### Optional - - let g:BufferListShowUnnamed = 1 - let g:BufferListShowTabFriends = 1 - let g:BufferListWidth = 25 - let g:BufferListMaxWidth = 50 - hi BufferSelected term=reverse ctermfg=white ctermbg=red cterm=bold - hi BufferNormal term=NONE ctermfg=black ctermbg=darkcyan cterm=NONE +Project moved here: [Vim-BufferList2](https://github.com/szw/vim-bufferlist2). The further +development will continued only there. License ------- From fff46795de3b2965cd2364e0bb14ff99d0761ae6 Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 24 May 2013 03:53:38 +0200 Subject: [PATCH 21/22] Update info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b3e10e..fb41fb7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ VIM bufferlist Deprecation warning ------------------- -Project moved here: [Vim-BufferList2](https://github.com/szw/vim-bufferlist2). The further +Project moved here: [VIM NextBufferList](https://github.com/szw/vim-next_bufferlist). The further development will continued only there. License From 417b62625f7e8ae3684cad871f1e64dccf20cc3a Mon Sep 17 00:00:00 2001 From: Szymon Wrozynski Date: Fri, 24 May 2013 04:08:19 +0200 Subject: [PATCH 22/22] Fix name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb41fb7..b0e7ed6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ VIM bufferlist Deprecation warning ------------------- -Project moved here: [VIM NextBufferList](https://github.com/szw/vim-next_bufferlist). The further +Project moved here: [Vim NextBufferList](https://github.com/szw/vim-next_bufferlist). The further development will continued only there. License