switch vim buffers

A better way to switch between vim buffers

Here is what it does:

  • switch between vim buffers with alt-tab
  • show all opened buffer in tabline on top while switching
  • hide the tabline while in insert mode

Put this in your .vimrc

function! SwitchBuffer()
    :set showtabline=2
    :bn
    augroup enable
        autocmd InsertEnter    * :set showtabline=0
    augroup END
endfunction

Note

this wont work without a plugin that shows all buffers in tabline, for vim itself doesn’t do that.

I’m using vim-bufferline + vim-lightline.

Alternatives: lightline-bufferline, airline etc. as long as it uses tabline for buffers list.

edited 20.04.2024
created 26.01.2021
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<