2

When vim is split into different panes horizontally, each pane has its own statusline. It's easy to highlight the statuslines differently based on current and non-current panes. BUT, I cannot figure out how to set different values for StatusLine and StatusLineNC. Only the former is recognized by vim/neovim.

My plan is replace the values of non-active statuslines with em-dashes, making it look like a line-divider between panes. The active pane will have a conventional statusline with the a filepath, columns, row, etc.

How do you set separate values for them? Is this possible? Suggestions?

Bonus question: how can you repeat a single char through a statusline?

  • StatusLine and the NC variant are highlight groups; if you are referring to the 'statusline' option, Im afraid there is only one. – D. Ben Knoble Aug 9 '18 at 22:04
  • 3
    correct, and there is no need for another option. You would set the statusline option to a function that checks what is the current window and returns the content for each statusline. This is basically what vim-airline does – Christian Brabandt Aug 10 '18 at 6:24
  • Trying to make Christian's comment more noob-friendly: you can tell vim to show what you want based on the current status of split with BufEnter and BufLeave autocommands. Suggesting looking into from @ChristianBrabandt – klaus Aug 10 '18 at 14:28
  • Thanks, all insightful answers! I see now that this is possible, albeit a little cumbersome. I'll need some actual understanding of vimscript, so I've started reading "Learning Vimscript the hard way". I'll post the solution once I'm done. – Audun Olsen Aug 10 '18 at 23:48
2

To change the divider for the none current window you can do this with (look up :help fillchars):

set fillchars=stlnc:-

To change some content depending on whether it is the current or none current window:

function SomeText(nr)
    let activebuffer = (a:nr == win_getid()) ? "Active Window" : "None Current Window"
    let buf_type = &buftype
    return activebuffer." & ".buf_type
endfun
function MyStatusLineWrapper() abort
    let startup_win_id = win_getid()
    let s = "%{SomeText(".startup_win_id.")} ".startup_win_id
    return s
endfun

set statusline=%!MyStatusLineWrapper()
| improve this answer | |

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.