I have two buffers, and would like one takes 1/4 of a window and other takes rest of the window.

Normal behavior would be for example sp or vsp would split buffer to take 50/50 percent each, there would be some buffers more important than others so that I raise this question.

In my case, I'd like to have a terminal buffer that takes 1/4 of a window and other takes the rest.

I used gvim 1-1802 on windows 10.

Many thanks.


1 Answer 1


You can use the &columns setting and some math to achieve this. Do you want to resize your existing splits, or make a new split at the right ratios? Since it's not entirely clear from your question, here's how you can do it both ways.

Resizing existing splits

I used this:

function! Quarter()
  exec "vertical resize ".(&columns / 4). " N"

This will resize the existing buffer to a quarter of the screen size. Of course, you can map this to a key, for example:

nnoremap <leader>q :call Quarter()<cr>


nnoremap <leader>q :exec "vertical resize ".(&columns / 4). " N"<cr>

Or you can bind this function to the VimResized event.

Making new splits

You can do this:

:exec (&columns / 4)." vsplit"

to make the current window 1/4 and the new window fill up the rest, or

:exec (&columns / 4 * 3)." vsplit"

to make the new window 1/4 and the current window fill up the rest.

  • Thanks. But how to have both columns and rows take 1/4 of a window? Append .(&rows / 4) seems doesn't work. I'd like to have look into both ways new and existing buffer. May 10, 2018 at 0:56
  • 1
    @TuyenPham If you're asking for how to get one window in one corner that is both half the width and half the height of the screen, with a single L-shaped window taking up the other three quarters of the area, that's not possible in Vim.
    – Rich
    May 10, 2018 at 9:04
  • @Rich: Is there a way to call new terminal buffer that takes 1/4 of a window base on rows in a new split buffer? I can't find :h rows in doc, so maybe there's no rows option. For example: :exec (&rows / 4 * 3)." vsplit :terminal" May 12, 2018 at 1:44
  • 1
    @TuyenPham The option is called 'lines'.
    – Rich
    May 15, 2018 at 12:10
  • @Rich: I'm trying to invoke new term via this command: nnoremap <c-w>l :exec terminal (&lines / 4 * 3)." vsplit" but it seems doesn't work, Did I miss something here? May 22, 2018 at 3:17

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.