Resizing windows
You can resize windows so that they fit your preferences.
The first thing to know is that the <C-w> bindings for creating windows accept counts, which you can use to set the size of the new window right from the get. For example <C-w>80s (or 80<C-w>s if you prefer — there’s no difference) will open up a new horizontal split that’s 80 characters high. You can do the same with <C-w>v — so <C-w>80v or 80<C-w>v — to open up a new vertical split that’s 80 characters wide.
If you want to resize windows after creating them, no problem — here are the bindings to know:
[count]<C-w>>increases the width of the current window by[count]columns.[count]<C-w><decreases the width of the current window by[count]columns.[count]<C-w>+increases the height of the current window by[count]rows.[count]<C-w>-decreases the height of the current window by[count]rows.
I personally find the bindings above a little bit fiddly though. Most of the time I find myself reaching for these ones instead:
[count]<C-w>|to set the width of the window to a fixed number of columns,[count]. If you don’t specify a count, Vim will maximise the window width as much as possible.[count]<C-w>_to set the height of the window to a fixed number of lines,[count]. If you don’t specify a count, Vim will maximise the window height as much as possible.
Finally — and this is a really useful one, so write this down! — <C-w>= will automatically resize all of your windows to sensible defaults in case you want to reset everything.
There are a lot of bindings for resizing windows! It kind of makes sense — there are lots of ways that windows can be resized.
In your local instance of Vim, you’ll be able to enable mouse support with set mouse+=a, which makes window resizing intuitive. Unfortunately you can’t do this in the embedded editor right now because it doesn’t support it yet — sorry about that!
Let’s try resizing some windows in the editor. Try:
- creating some windows with a pre-determined size with
[count]<C-w>sand[count]<C-w>v - resizing some existing windows with
[count]<C-w>>,[count]<C-w><,[count]<C-w>+, and[count]<C-w>- - setting the size of some window with
[count]<C-w>|and[count]<C-w><,[count]<C-w>+, and[count]<C-w>- - getting back to some sensible default window sizes with
<C-w>=