1

I'm setting up NeoFormat/ALEfix-style code reformatting, and I'd really like to have it automatically and fluidly reformat the code as the window is resized. This is possible for whole-viewport vim-windows with the VimResized autocmd; but I see no corresponding WinResized autocmd.

Is there an efficient way to add some buffer-local behaviour (i.e. as mentioned above, running code through a width-aware reformatter) to be preformed every time a Vim window is resized (i.e. ⌃w =, :vertical resize 100, et. al)

1 Answer 1

1

Currently, there's no autocommand for this (although it would be very useful).

A possible way to do this is to poll vim every CursorHold event, and check to see if the window size has changed; the winwidth() and winheight() functions can give the current height of a window. By default CursorHold is triggered after 4 seconds of vim receiving no input, but that can be reduced by changing the 'updatetime' option. Not exactly fluid but better than nothing.

(Everything marked in code blocks can be looked up in vim's help by passing it exactly as written to :h)

Your Answer

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

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