Wednesday, June 17, 2009

Switching from Horizontal to Vertical Split

If you have two windows which are horizontally split, and you'd like to make them vertically split instead, the following command sequence works well:

<ctrl-w>t<ctrl-w>H

To orient them back to a horizontal split do this:

<ctrl-w>t<ctrl-w>K

Note that if the top (or left) window is already current you can omit the <ctrl-w>t and simply do <ctrl-w>H or <ctrl-w>K.

3 comments:

Unknown said...

Since we are talking about split windows, I've been looking for a way to set a permanent width for a vertical split, to be used as "file selector". Any ideas/pointers?

Chris said...

NerdTree works well for file browsing; I use

map _leader_n :NERDTreeToggle _CR_
(grr tags)
in my bashrc for a quick toggle; really useful.

http://www.vim.org/scripts/script.php?script_id=1658

Allan Kelly said...

Fab, thanks for this. The documentation at :h CTRL-W_H describes a manual process this imitates, which is what I've been doing! This saves me loads of hassle. I wasn't aware of these commands. I also like CTRL-W_T.

These commands were addded because somebody needed them. I added the functionality documented at :h blockwise-operators for the same reason. You may not know about those! v_b_I and v_b_A are particularly useful. I hope you find them useful.

Thanks again, al.