Search code examples
vimpowerline

How to show all buffers in vim using powerline?


I want to show all buffers' names on statusline(I use powerline). And I hope current buffer can be highlighted, while others are not. When I use :bn or :bp it highlights the changed buffer. How can I make it?


Solution

  • I don't know how to do such a thing with powerline, however I have come across vim-buftabline which does what you ask but with the tabline instead of the statusline.

    Personally, I would forget doing this in the statusline or tabline, because it is very easy to run out of space on either line. I would also stop using :bn/:bp and just use :b instead to jump directly to the buffer in question.

    Behold the power of :b:

    • Uses <tab> completion
    • Use <c-d> to list out completion
    • Use partial file name. e.g. :b foo. Works great with <tab>.
    • Globbing. e.g. :b foo*bar or :b foo/**/bar
    • Might want to use 'hidden' via set hidden
    • Split variant of :b is :sb.
    • Also accepts a buffer number

    A common mapping:

    nnoremap <leader>b :ls<cr>:b<space>
    

    For more help see:

    :h :b
    :h :ls
    :h 'switchbuf'
    :h 'hidden'
    :h 'tabline'