0

I'm using vim-autoresize for resize windows. It uses:

augroup _vim-autoresize
    autocmd!
    autocmd WinEnter * call autoresize#resize()
augroup end

But WinEnter just changes behavior when your cursor in another window and jump back

enter image description here

How autoresize when open the window?

1 Answer 1

0

If you want the effect only on opening new window, then try WinNew or BufWinEnter as WinEnter triggers every time you enter a window.

You can add another autocmd for the cases when you want to call the function:

augroup _vim-autoresize
    autocmd!
    " Resize a newly opened one
    autocmd BufWinEnter * call autoresize#resize()
    " Resize upon switching window
    autocmd WinEnter    * call autoresize#resize()
augroup end
11
  • I want apply both when open new window and after jump to other window. How to do that?
    – Pham Hung
    Feb 15, 2022 at 8:16
  • you can add another autocmd, as in my edited answer.
    – Rekkhan
    Feb 15, 2022 at 9:33
  • Thanks for your help, I found the answer with your code, change BufWinEnter to BufNew, but it just work with normal buffer, not help file buffer
    – Pham Hung
    Feb 15, 2022 at 13:49
  • it seems to me that this if block was executed. Can you :echo g:autoresize_disabled_filetypes? We may need to know what it contains.
    – Rekkhan
    Feb 15, 2022 at 15:31
  • I just set ['nerdtree'] for this variable
    – Pham Hung
    Feb 16, 2022 at 5:09

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.