Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make windows equal horizontally or vertically by shortcuts?

Tags:

vim

I am looking for the way to make Vim windows equal only vertically or horizontally, not both at the same time. For example, I want ^W= to affect only window width and ^W=| to affect only its height. Is this possible?

UPDATE

Thanks to @rburny who suggest the appropriate commands. So the final result is:

nmap <c-w>== :set ead=ver ea noea<CR> " set windows equal vertically (^W, =, =)
nmap <c-w>=- :set ead=hor ea noea<CR> " set windows equal horizontally (^W, =, -)

If you want to set windows equally both, just press ^W= and wait for a moment.

like image 665
Timur Fayzrakhmanov Avatar asked Oct 28 '15 12:10

Timur Fayzrakhmanov


People also ask

How do I quickly arrange windows side by side?

In the taskbar, click the button for the first window you want to position, then hold the Ctrl key and right-click the button for the second window. Select Tile Vertically. Bingo, the two windows are positioned side by side. (If you pick Tile Horizontally then they appear one above the other.)

How do I open two windows side by side shortcuts?

Press the Windows key and press either the right or left arrow key, moving the open window to the screen's left or right position. Choose the other window you want to view next to the window in step one.

How do I horizontally align a window?

View > Arrange Window > Arrange Horizontally applies to all document windows that are open. However, you can use the SHIFT and CTRL keys in the Window List dialog box to select specific windows and arrange them vertically or horizontally.

What are the 3 ways your windows can be tiled on the desktop?

Right-click the taskbar and you'll see three window management options — Cascade windows, Show windows stacked, and Show windows side by side.


1 Answers

I'm assuming you don't use equalalways option, since you want to do such operations manually. In this case, you can hack equalalways to do what you want:

" make all windows the same height
:set ead=ver ea noea
" make all windows the same width
:set ead=hor ea noea

What these commands do is basically:

  • set preferred direction for equalalways (vertical / horizontal)
  • enable & disable equalalways, which causes the windows in a current tab to be made equal in chosen direction

Obviously, you can map these commands to any key sequence.

like image 79
rburny Avatar answered Oct 13 '22 21:10

rburny