neoVim:在缓冲区中循环时,忽略其他窗格中打开的缓冲区



假设我有两个垂直拆分的窗格,打开了多个缓冲区。我在左窗格中打开了file-a.txt/buffer 1,并且我的光标集中在右窗格上。在右侧窗格中,我希望在不经过file-a.txt/buffer 1的情况下循环浏览其余打开的缓冲区。

也就是说,当在另一个窗格中的缓冲区时,我希望忽略在其他窗格中打开的缓冲区。这可能吗?

谢谢。

简单的解决方案是检查缓冲区是否在其他窗口中打开。如果是,则只需再次执行bnext

function! Bnext() abort
bnext                                " Go to next buffer.
if len(win_findbuf(bufnr('%'))) > 1  " If buffer opened in more than one window,
call Bnext()                       "  then call func again to go to next one.
endif
endfunction
nnoremap <leader>b :call Bnext()<CR>

相关内容

最新更新