Skip to content

Commit 04d1abf

Browse files
author
huzilin
committed
Add switch to next buffer and prev buffer
1 parent 0b9f611 commit 04d1abf

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

autoload/buffet.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,16 @@ function! buffet#bswitch(index)
360360
execute 'silent buffer ' . buffer_id
361361
endfunction
362362

363+
function! buffet#bnext()
364+
let next_buffer_id = (s:last_current_buffer_id+1)%len(s:buffer_ids)
365+
call buffet#bswitch(next_buffer_id)
366+
endfunction
367+
368+
function! buffet#bprev()
369+
let next_buffer_id = (s:last_current_buffer_id-1)
370+
call buffet#bswitch(next_buffer_id)
371+
endfunction
372+
363373
" inspired and based on https://vim.fandom.com/wiki/Deleting_a_buffer_without_closing_the_window
364374
function! buffet#bwipe(bang, buffer)
365375
let btarget = s:GetBuffer(a:buffer)

plugin/buffet.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ for s:n in range(0, g:buffet_max_plug)
243243
execute printf("noremap <silent> <Plug>BuffetSwitch(%d) :call buffet#bswitch(%d)<cr>", s:n, s:n)
244244
endfor
245245

246+
noremap <silent> <Plug>BuffetNext :call buffet#bnext()<cr>
247+
noremap <silent> <Plug>BuffetPrev :call buffet#bprev()<cr>
248+
246249
command! -bang -complete=buffer -nargs=? Bw call buffet#bwipe(<q-bang>, <q-args>)
247250
command! -bang -complete=buffer -nargs=? Bonly call buffet#bonly(<q-bang>, <q-args>)
248251

0 commit comments

Comments
 (0)