From 31eda78a8b0709d160493066b4ec69e2c3e5e83a Mon Sep 17 00:00:00 2001 From: Pixeller Date: Wed, 15 Feb 2023 06:13:53 +0800 Subject: [PATCH 1/4] Update 2023 Fix some bug and add hotkey, You can see readme.txt --- README.md | 30 ++++++++++++++++++++++++++++++ plugin/qbuf.vim | 47 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..56dccf8 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +Copy by [vim-scripts/QuickBuf](http://www.vim.org/scripts/script.php?script_id=1910) + +QuickBuf +--- +>Vim plugin helps navigate and manipulate buffers + +**Brief description:** +>While making the task of browsing and manipulating buffers visual and simple, QuickBuf also offers advanced abilities of dealing with buffers (ex: "unlisted" mode). It's unique among several other buffer managers for creating no dedicated buffer and defining no auto command, thus minimize its interference. + +**Usage:** +>+ Press the assigned hotkey to activate QuickBuf (default ). It brings out a list of buffers that you can browse and give commands on! Some indicators in the list: + - * : the buffer being opened in the active window + - = : a buffer being opened in a window, but not active + - [+] : modifed buffer +>+ Use k/j or / keys to select the buffer. +>+ Press a key to give a command to the currently selected buffer + - d/D : del/!delete buffer + - w/W : wipe/!wipe out buffer + - s : open buffer in a new horizontally split window + - v : open buffer in a new vertically split window + - f : open buffer + - e : quickly switch buffer in current window + - : open buffer and leave QuickBuf; if the buffer is already opened in a window, switch to that window. +>+ d, w, and operations may fail, You can use D, W force operation +>+ Instead of moving the selection bar around to select a buffer, you can use a number to specify a buffer. For example: '2d' will delete the second buffer in the list. Try '3f', '1w', '1!w' or '1W' +>+ Use 'l' key to toggle between LISTED and UNLISTED mode. Which mode QuickBuf enter first depends on the active buffer. While in UNLISTED mode, 'unlisted' buffers (the buffers you have deleted) are showed. Also: + - [+] indicates a loaded buffer + - 'd' command makes the selected buffer 'listed' again +>+ Press \/q key to leave QuickBuf + diff --git a/plugin/qbuf.vim b/plugin/qbuf.vim index db5678f..7afe789 100644 --- a/plugin/qbuf.vim +++ b/plugin/qbuf.vim @@ -1,25 +1,35 @@ +"===================== +" QuickBuf +" version 1.69 +"===================== if v:version < 700 finish endif -if !exists("g:qb_hotkey") || g:qb_hotkey == "" - let g:qb_hotkey = "" -endif -exe "nnoremap " g:qb_hotkey " :cal init(1):cal SBRun()" -exe "cnoremap " g:qb_hotkey "" - if exists("g:qb_loaded") && g:qb_loaded finish endif let g:qb_loaded = 1 -let s:action2cmd = {"z": 'call switchbuf(#,"")', "!z": 'call switchbuf(#,"!")', - \"u": "hid b #|let s:cursel = (s:cursel+1) % s:blen", +if !exists("g:qb_hotkey") || g:qb_hotkey == "" + let g:qb_hotkey = "" +endif +exe "nnoremap " g:qb_hotkey " :cal init(1):cal SBRun()" + +let s:action2cmd = { + \"z": 'call switchbuf(#,"")', "!z": 'call switchbuf(#,"!")', + \"f": 'call switchbuf(#,"")', "!f": 'call switchbuf(#,"!")', + \"F": 'call switchbuf(#,"!")', \"s": "sb #", + \"v": "vert sb #", + \"e": "hid b #|let s:cursel = (s:cursel+1) % s:blen", \"d": 'call qbufdcmd(#,"")', "!d": 'call qbufdcmd(#,"!")', + \"D": 'call qbufdcmd(#,"!")', \"w": "bw #", "!w": "bw! #", + \"W": "bw! #", \"l": "let s:unlisted = 1 - s:unlisted", - \"c": 'call closewindow(#,"")'} + \"c": 'call closewindow(#,"")' + \} function s:rebuild() redir @y | silent ls! | redir END @@ -62,6 +72,9 @@ function SBRun() if !exists("s:cursel") || (s:cursel >= s:blen) || (s:cursel < 0) let s:cursel = s:blen-1 endif + if !exists("s:old_cursel") + let s:old_cursel = s:cursel + endif if s:blen < 1 echoh WarningMsg | echo "No" s:unlisted ? "unlisted" : "listed" "buffer!" | echoh None @@ -98,6 +111,7 @@ function SBRun() call s:setcmdh(s:blen+1) endfunc +let s:klist = ["j","J","k","K", "f", "F", "e", "d", "D", "w", "W", "l", "s", "v", "c", "q"] function s:init(onStart) if a:onStart set nolazyredraw @@ -105,14 +119,19 @@ function s:init(onStart) let s:cursorbg = synIDattr(hlID("Cursor"),"bg") let s:cursorfg = synIDattr(hlID("Cursor"),"fg") let s:cmdh = &cmdheight - hi Cursor guibg=NONE guifg=NONE + "hi Cursor guibg=NONE guifg=NONE - let s:klist = ["j", "k", "u", "d", "w", "l", "s", "c"] for l:key in s:klist - exe "cnoremap ".l:key." ".l:key.":cal SBRun()" + if l:key == "q" + exe "cnoremap ".l:key." :cal s:init(0):echo''" + else + exe "cnoremap ".l:key." ".l:key.":cal SBRun()" + endif endfor cmap k cmap j + cnoremap + exe "cnoremap :cal s:init(0):echo''" call s:rebuild() let s:cursel = match(s:buflist, '^\d*\*') @@ -124,7 +143,9 @@ function s:init(onStart) endfor cunmap cunmap - exe "hi Cursor guibg=" . s:cursorbg . " guifg=".((s:cursorfg == "") ? "NONE" : s:cursorfg) + cunmap + cunmap + "exe "hi Cursor guibg=" . s:cursorbg . " guifg=".((s:cursorfg == "") ? "NONE" : s:cursorfg) endif endfunc From 291d2d4018b96853b0de0937874c441d3849e860 Mon Sep 17 00:00:00 2001 From: Pixeller Date: Wed, 15 Feb 2023 06:19:22 +0800 Subject: [PATCH 2/4] Delete README --- README | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 README diff --git a/README b/README deleted file mode 100644 index cccf9ca..0000000 --- a/README +++ /dev/null @@ -1,30 +0,0 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=1910 - -QuickBuf -Vim plugin helps navigate and manipulate buffers -Maintainer: palnart - -Brief description: -While making the task of browsing and manipulating buffers visual and simple, QuickBuf also offers advanced abilities of dealing with buffers (ex: "unlisted" mode). It's unique among several other buffer managers for creating no dedicated buffer and defining no auto command, thus minimize its interference. - -Give it a try and you may find it all you need to work with Vim's buffers! -Any bugs or suggestions, please mail to: palnart@gmail.com - -Usage: -+ Press the assigned hotkey to activate QuickBuf (default ). It brings out a list of buffers that you can browse and give commands on! Some indicators in the list: - - * : the buffer being opened in the active window - - = : a buffer being opened in a window, but not active - - [+] : modifed buffer -+ Use k/j or / keys to select the buffer. -+ Press a key to give a command to the currently selected buffer - - d : delete buffer - - w : wipe out buffer - - s : open buffer in a new horizontally split window - - u : open buffer - - : open buffer and leave QuickBuf; if the buffer is already opened in a window, switch to that window. -+ d, w, and operations may fail (ex: delete a modified buffer), QuickBuf will inform you so that you can force them by preceding the above characters with an exclamation mark ('!'). Ex: !d, !w, ! -+ Instead of moving the selection bar around to select a buffer, you can use a number to specify a buffer. For example: '2d' will delete the second buffer in the list. Try '3', '1w', '1!w' -+ Use 'l' key to toggle between LISTED and UNLISTED mode. Which mode QuickBuf enter first depends on the active buffer. While in UNLISTED mode, 'unlisted' buffers (the buffers you have deleted) are showed. Also: - - [+] indicates a loaded buffer - - 'd' command makes the selected buffer 'listed' again -+ Press key to leave QuickBuf From 1d1d993a70aacf9f2b74180549c1a40917f0633f Mon Sep 17 00:00:00 2001 From: Pixeller Date: Sun, 14 May 2023 19:42:33 +0800 Subject: [PATCH 3/4] Update qbuf.vim --- plugin/qbuf.vim | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugin/qbuf.vim b/plugin/qbuf.vim index 7afe789..7f15da0 100644 --- a/plugin/qbuf.vim +++ b/plugin/qbuf.vim @@ -1,6 +1,6 @@ "===================== " QuickBuf -" version 1.69 +" version 1.7 "===================== if v:version < 700 finish @@ -75,6 +75,10 @@ function SBRun() if !exists("s:old_cursel") let s:old_cursel = s:cursel endif + if !exists("s:hasMore") + let s:hasMore = &more + endif + set nomore if s:blen < 1 echoh WarningMsg | echo "No" s:unlisted ? "unlisted" : "listed" "buffer!" | echoh None @@ -106,6 +110,9 @@ function SBRun() endif elseif s:update_buf(l:pkey) call s:init(0) + if s:hasMore + set more + endif return endif call s:setcmdh(s:blen+1) @@ -181,8 +188,10 @@ endfunc function s:setcmdh(height) if a:height > &lines - winnr('$') * (&winminheight+1) - 1 - call s:init(0) - echo "\r"|echoerr "QBuf E1: No room to display buffer list" + "call s:init(0) + "exe "set cmdheight=".s:blen + exe "set cmdheight=".1 + "echo "\r"|echoerr "QBuf E1: No room to display buffer list" else exe "set cmdheight=".a:height endif From 0b038382117afeeb185b4592bef66e1f32736bfb Mon Sep 17 00:00:00 2001 From: Pixeller Date: Thu, 18 May 2023 16:34:36 +0800 Subject: [PATCH 4/4] Add J/K g/G key select buffer --- README.md | 2 +- plugin/qbuf.vim | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 56dccf8..6d8426f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ QuickBuf - * : the buffer being opened in the active window - = : a buffer being opened in a window, but not active - [+] : modifed buffer ->+ Use k/j or / keys to select the buffer. +>+ Use j/k \/\ J/K goto prev+/next+ line, g/G goto first/last line >+ Press a key to give a command to the currently selected buffer - d/D : del/!delete buffer - w/W : wipe/!wipe out buffer diff --git a/plugin/qbuf.vim b/plugin/qbuf.vim index 7f15da0..44aae34 100644 --- a/plugin/qbuf.vim +++ b/plugin/qbuf.vim @@ -100,14 +100,24 @@ function SBRun() if s:unlisted echoh None endif - if l:pkey =~ "j$" + if l:pkey =~# "j$" let s:cursel = (s:cursel+1) % s:blen - elseif l:pkey =~ "k$" + elseif l:pkey =~# "k$" if s:cursel == 0 let s:cursel = s:blen - 1 else let s:cursel -= 1 endif + elseif l:pkey =~# "J$" + let l:cl = s:cursel+5 + let s:cursel = l:cl > s:blen ? s:blen : l:cl + elseif l:pkey =~# "K$" + let l:cl = s:cursel-5 + let s:cursel = l:cl < 0 ? 0 : l:cl + elseif l:pkey =~# "G$" + let s:cursel = s:blen + elseif l:pkey =~# "g$" + let s:cursel = 0 elseif s:update_buf(l:pkey) call s:init(0) if s:hasMore @@ -118,7 +128,7 @@ function SBRun() call s:setcmdh(s:blen+1) endfunc -let s:klist = ["j","J","k","K", "f", "F", "e", "d", "D", "w", "W", "l", "s", "v", "c", "q"] +let s:klist = ["j","J","k","K","g","G","f","F","e","d","D","w","W","l","s","v","c","q"] function s:init(onStart) if a:onStart set nolazyredraw