← Back to Upcase

The Art of Vim: Splits


This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/splits-with-patrick-brisbin

I really like the final workings on the configuration shown in the video.
However, please post the configurations in video notes. It is not very clear from the video which line would affect what change in the behaviour.

Hey Ankit!

You can probably find the info you’re looking for in vim’s help.

Try :h 'winwidth' or :h 'winheigh', for example.

(Note the single quotes, which tell vim you want info on an option, which these are.)

I agree with @ankitml , this is a brilliant idea. However the numbers within the video don’t really work when you have a large monitor, it really appears to do nothing.

I found this: https://github.com/roman/golden-ratio however, which on a large or small monitor.

And, if you don’t want it to happen automatically with that plugin, you can turn it off like I did.

" Golden Ratio Split
let g:golden_ratio_autocommand = 0
" Mnemonic: - is next to =, but instead of resizing equally windows are resized to 
  focus on the current.
nmap <silent> <C-w>- <Plug>(golden_ratio_size)
" Fill screen with current window
nnoremap <C-w>+ <C-w><Bar><C-w>_

And with these mappings, it stays equalized out unless I do <C-w>- which will bring focus to the active window. And if I need more focus, <C-w>+ brings it to being ‘full screen’ which works out great.

@ch0ke

Thanks for the note on the golden-ratio plugin – very useful. Great suggestion also with the window size mappings.

Just a small correction – it looks like (golden_ratio_size) should be (golden_ratio_resize)

In my setup, I went with defaulting to having the golden ratio resizing on and then added an extra mapping to toggle the golden ratio sizing on/off:
nmap t (golden_ratio_toggle)

I also liked the idea of keeping the splits to having a minimum height of 5 lines so kept in:
set winheight=5
set winminheight=5

It works great. I can toggle the golden ratio sizing on or off, and the window resizing never goes below the minimum 5 lines height. This does mean that a window with a horizontal split will not go entirely full size with the + mapping though.