From 56378a3eaeb5f7d308a379d3c3b405bc53d69f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20BENO=C3=8ET?= Date: Sat, 24 Jun 2023 18:20:06 +0200 Subject: [PATCH] Buffer control commands * Mappings to space-lead sequences * New commands (close all, new) --- cfg/15-buffers.vim | 14 ++++++++++---- plugins/vim-which-key.post.vim | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cfg/15-buffers.vim b/cfg/15-buffers.vim index 244e919..6f108aa 100644 --- a/cfg/15-buffers.vim +++ b/cfg/15-buffers.vim @@ -1,9 +1,5 @@ set hidden " Don't close buffers -" Buffer navigation -nnoremap :bprev -nnoremap :bnext - " Close buffer function CloseCurrentBuffer( ) let btarget = bufnr( '%' ) @@ -42,4 +38,14 @@ function CloseCurrentBuffer( ) execute l:wcurrent . 'wincmd w' endfunction +" Buffer navigation (Ctrl, Shift, Arrows...) +nnoremap :bprev +nnoremap :bnext nnoremap :call CloseCurrentBuffer() + +" Buffer navigation (Space sequences) +nnoremap bz :enew +nnoremap bq :bprev +nnoremap bd :bnext +nnoremap bw :call CloseCurrentBuffer() +nnoremap bW :bufdo call CloseCurrentBuffer() diff --git a/plugins/vim-which-key.post.vim b/plugins/vim-which-key.post.vim index 20df7a9..81fb275 100644 --- a/plugins/vim-which-key.post.vim +++ b/plugins/vim-which-key.post.vim @@ -20,6 +20,14 @@ let g:which_key_map.o.p = 'paste' let g:which_key_map.o.w = 'whitespace' let g:which_key_map.o.s = 'sign-column' +" Buffers +let g:which_key_map.b = { 'name' : '+buffers' } +let g:which_key_map.b.W = 'close-all' +let g:which_key_map.b.d = 'next' +let g:which_key_map.b.q = 'previous' +let g:which_key_map.b.w = 'close' +let g:which_key_map.b.z = 'new' + " Fuzzy finder let g:which_key_map.p = { 'name' : '+fuzzy-finder' } let g:which_key_map.p.p = 'buffers'