How do you prefer to switch between buffers in Vim?

前端 未结 16 2074
小蘑菇
小蘑菇 2020-12-12 08:33

I\'ve tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I\'d like is something like LustyJuggler with incremental sear

相关标签:
16条回答
  • 2020-12-12 09:23
    nmap <Leader>bb :ls<CR>:buffer<Space>
    

    and nobody mentioned nice plugin ctrlp.vim. Using this plugin you can search buffer by name.

    0 讨论(0)
  • 2020-12-12 09:24

    The excellent Buffer Explorer, the be has gotten to be such strong muscle memory that I find myself wishing I could use it in other applications. I find it to be extremely fast when actively editing more than two files.

    0 讨论(0)
  • 2020-12-12 09:28

    I like "ctrl-w s" and "ctlr-w v" to split the window. Then I map the movement keys (h, j, k, l) with ctrl held down to move between the split windows:

    " Map ctrl-movement keys to window switching
    map <C-k> <C-w><Up>
    map <C-j> <C-w><Down>
    map <C-l> <C-w><Right>
    map <C-h> <C-w><Left>
    

    Having to move my hand over to the arrow keys is annoying.

    Next, I set up ctlr-tab to switch between buffers in the current window (like a lot of other environments):

    " Switch to alternate file
    map <C-Tab> :bnext<cr>
    map <C-S-Tab> :bprevious<cr>
    

    These have worked pretty well for me over the last several years although vim always has more secrets than you can know.

    0 讨论(0)
  • 2020-12-12 09:31

    When there are several buffers open in a Vim session, it can become difficult to keep track of the buffers and their respective buffer numbers. If this is the case, switching to a different file can be made easier using a simple map:

    :nnoremap (F5) :buffers(CR):buffer(Space)

    vim.wikia.com

    0 讨论(0)
提交回复
热议问题