1

Couldn't find anything in autocommand-events, but is there may be a way to be notified if window split size was changed (with mouse or with C-w +)?

What I try to achieve is to be able to auto-save the window layout if size was changed.

PS: that is for my WIP plugin https://github.com/habamax/vim-winlayout which is heavily inspired by and uses code from @dedowsdi answer

  • Or maybe I should add timer event for this? Checking current win sizes against previous? – Maxim Kim Jan 28 at 13:37
  • 1
    Yeah i saw that this morning. Didn't find any winresized events unfortunately. – D. Ben Knoble Jan 28 at 14:21
3

One undocumented trick is to use %{MyFunc()} expression in the statusline syntax. MyFunc() is always called whenever something happens so you can check the window size in it.

For example, You can see the window height/width in the statusline.

function! EchoWinSize()
   return winheight(0) . '/' . winwidth(0)
endfunction
let &statusline = "%{EchoWinSize()}"

As well as the statusline, guitablabel, iconstring, rulerformat, tabline, titlestring options support the statusline syntax.

However, I am not sure about its negative side effect.

I found this trick since I have been looking for something like a WindowScrolled event, but not yet implemented. In my plugin, I am thinking to use iconstring, which seems not to be used so common, to check the window scroll.

| 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.