1

I have a tab with the following window structure:

_________________________________
1              | 3               |
               |                 |
               |                 |
_______________|_________________|
4              | 5               | 
               |                 |
               |                 |
_______________|_________________|

Numbers indicated the buffer numbers provided automatically by vim. I have vim-airline that I was hoping would help me figure out which window I am currently focused on and which buffer I am editing. Please see gif here, reproduced below:

enter image description here

Buffer 1 is .vimrc, 3 is Main1.cpp, 4 is include1.h and 5 is include2.h.

As I move clockwise, the tabline in the bottom of each window gets highlighted indicating which window I am focussed on. However, the tabline does not work properly in buffers/windows 1 and 3. Essentially, in 1 (especially) and 3, I do not get to see 1:.vimrc and 3:Main1.cpp in the tablines for these specific windows clearly because the available space is crowded/joslted out unnecessarily for these windows by 4:include1.h and 5:include2.h, which are irrelevant in these windows. Is there a way that the tabline can highlight the buffer name completely even if there are other buffers jostling for space on the same tabline?

Because this could be behavior due to possibly some plugins that I have, in the image above, buffer 1 lists all the plugins I have currently installed.

Is there a way to fix this?

16
  • 1
    according to your screenshot, you have not enabled the tabline feature of vim-airline. Please do so (hint: look into the documentation) Sep 20, 2021 at 16:35
  • 1
    I looked at the documentation and set let g:airline#extensions#tabline#enabled = 1 That indeed shows a highlight on top which highlights which buffer I am on. Thanks for your help! I learned today that a tabline is different from a statusline. Just to cofirm, even if there is only a single tab, the tabline refers to the line on top, that is shared across all windows, while a status line is for each window. Is my understanding correct? Thanks again for your help!
    – Tryer
    Sep 20, 2021 at 16:45
  • 1
    Simple fix: don’t include the full buffer or argument list in the status line; save room by just using the current buffer name.
    – D. Ben Knoble
    Sep 21, 2021 at 11:29
  • 2
    Better solution: drop that garbage and use the default status line and tab line.
    – romainl
    Oct 19, 2022 at 6:19
  • 1
    @VivianDeSmedt Your wish is my command :-)
    – Tryer
    Oct 18, 2023 at 2:50

1 Answer 1

1

After looking through ways of customizing the vim-airline status line, and also looking at how default vim's inbuilt status lines work, I have ended up using the following in my .vimrc

let g:customstatusline = 0 " can be 0 or 1

if g:customstatusline == 0
  let g:airline#extensions#tabline#enabled = 1
  let g:airline_section_c='%f %m %{tagbar#currenttag("%s ","","f")} %l of %L %P'
  let g:airline_section_x=''
  let g:airline_section_y=''
  let g:airline_section_z=''
else
  set laststatus=2
  set statusline=%f\ %m%{tagbar#currenttag('%s\ ','','f')}%l,%L\ %P
  let g:bufferline_active_buffer_left = '[[['
  let g:bufferline_active_buffer_right = ']]]'
endif

In the case of g:customstatusline==0, I provide a very minimal vim-airline that includes the filename of the current buffer only, whether it is modified or not, the current symbol cursor is in (requires tagbar plugin), which line the cursor is on currently, how many total lines are in the buffer and what percentage of movement within the buffer is covered. Sections x, y and z of the status bar are set to null values. This works for me.

I also found my own custom setting of the status line can also do the job. That is the else case. Here, I display the same content as the case above. The currently active buffer is visually highlighted thus: [[[ currently_active_buffer ]]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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