History Report a problem
Article Edit this page Discussion

How to toggle between all vertical and all horizontal window layout

From Vim Tips Wiki

(Redirected from VimTip862)
Jump to: navigation, search
 

Tip 862Previous TipNext Tip

Created: January 25, 2005 Complexity: intermediate Author: Charles E. Campbell, Jr. Minimum version: 6.0 Karma: 81/44 Imported from: Tip#862


Suppose you have three windows in a "horizontal list", like this:

W|W|W

Entering the command:

:windo wincmd K

will change the windows to a "vertical list", like this:

W
W
W

Starting with a "vertical list", entering the command:

:windo wincmd H

will change the windows to a "horizontal list".

[edit] Comments

Very useful, I already added it as a command to my vimrc:

command -nargs=0 MyArrangeWindowsVertically :windo wincmd K
cnoremap <unique> myawv MyArrangeWindowsVertically
command -nargs=0 MyArrangeWindowsHorizontally :windo wincmd H
cnoremap <unique> myawh MyArrangeWindowsHorizontally

I should mention that there's a shorter pair of commands that almost does the same thing:

:sba
:vert sba

The difference is that these two commands will open a window for all buffers on the buffer list, not just re-arrange the display of current windows. Try :ls! to see the buffer list.


The following two maps help with window resizing:

nmap + <C-W>+
nmap - <C-W>-

I've written a small plugin (twl.vim) that implements :TWL (toggle window layout) which detects which type of window layout you currently have (vertical vs horizontal) and applies the correct command to toggle the layout. Its at http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs (see "Toggle Window Layout").


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Terminator Wiki
Legend of Zelda Wiki
Flash Gordon
Everquest II Wiki
Yo-Yo Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"How to toggle between all vertical and all horizontal window layout"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation