0

Currently my buffer bar (I don't know if this is the right word) looks like this:

enter image description here

Even though my terminal is super wide, it displays the names of only 4 buffers I have open and then an ellipsis (...) indicating I have more.

However, I would like it to fill up almost the entire width of the page with buffers, until it actually can't fit anymore and then use the ellipsis.

I use vim-airline.

1

Since you only posted a part of the whole picture, this all is just my guess.

I think that "buffer bar" is :h tabline. They display the current buffer in the corresponding tabs. I guess there are only 4 :h tabpages in that current session and thus only 4 filenames showing.

To give you a solution, I would say not to use tabline as tabs in other general text editors. The tabpage in vim is supposed to work like separating sessions.

Let's examine some terminologies:

  • A buffer is the in-memory text of a file.
  • A window is a viewport on a buffer.
  • A tab page is a collection of windows.

So, the usage of tabpage is twofolds:

  • Managing splits
    Assume, you have set up a beautiful set of splits which you don't want to lose. Now what do you do if you want to look at a buffer with full window height and width? You could do :h CTRL-W_bar and :h CTRL-W__ but that would mess up your current splits. So, instead you should open a new tabpage and view that buffer with full height and width, and when you're done you can get back to your previous tabpage where your previously setup splits are left untouched.

  • Managing projects
    Assume, you have a project in ~/projects/project_1 and you open vim in there. Your current working directory in the current session is ~/projects/project_1. Now, if you have to check on a separate project, you could open up another terminal and use a separate vim instance to work in that project. But if project_1 is dependent on project_2 or vice versa, and you need to work on both projects in the same vim instance, because of :h ins-completion etc. you can open a separate tabpages dedicated to each projects and change the current working directory corresponding to that tabpage with :h lcd. Now, you have two separate working projects with separate working directories but in the same vim instance.

Bottom line, :h tabpage is not supposed to be used for showing available buffers. You have :h :ls for that.

  • I find it convenient and pretty to have the files I'm working on visible at a glance like that, and seeing filenames is also useful to me. Running :ls every time sounds tedious. – theonlygusti Apr 8 at 10:02
  • Your answer is better. Thanks for teaching me how to use vim like a l33t h4ck3r – theonlygusti Apr 8 at 10:12
  • Sorry, I don't understand. What do you want to say? Do you disagree on some points? Are my guesses totally wrong? – klaus Apr 8 at 13:52
  • Well, the first comment is how I felt when i initially read your answer, the second comment is me changing my mind and deciding to learn to use vim a "different' way (which you and many other people much more efficient than me in vim recommend) – theonlygusti Apr 8 at 17:30
  • To reiterate, I have no "beef" with people trying to make things pretty, that's a valid philosophy. I once wasted 2 hours trying to find a "minimal" wallpaper! Secondly, for your issue of reusing :ls, I use :nnoremap <Space>b :ls<CR>:b<Space> when I need to change buffers. It shows me the list of available buffers and put me in command-line-mode to switch buffers, which I can do by using :h bufnr() that are printed on the left side, or the substring from the :h bufname() that are printed on the right side of :ls output. So, just hang on a little and follow some expert people's blogs – klaus Apr 8 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.