Vim Tips Wiki
Register
(reworked the tip)
Wetlife (talk | contribs)
No edit summary
Tag: Visual edit
 
(11 intermediate revisions by 10 users not shown)
Line 5: Line 5:
 
|created=April 26, 2006
 
|created=April 26, 2006
 
|complexity=basic
 
|complexity=basic
|author=Robert
+
|author=Robert & Bill
|version=6.0
+
|version=7.0
 
|rating=4/4
 
|rating=4/4
 
|category1=Split windows
 
|category1=Split windows
 
|category2=
 
|category2=
 
}}This tip is about how to resize {{help|prefix=no|usr_08.txt|Windows}} efficiently.
}}
 
   
  +
====== Window resizing ======
This tip is about how to resize {{help|prefix=no|usr_08.txt|Windows}} efficiently.
 
 
You can use the <code>:resize</code> command or its shortcut <code>:res</code> to change the height of the window. To change the height to 60 rows, use:<pre>
 
:resize 60
 
</pre><br />
  +
You can also change the height in increments. To change the height by increments of 5, use:<pre>
 
:res +3.5
 
:res 4
 
</pre><br />
  +
You can use <code>:vertical resize</code> to change the width of the current window. To change the width to 80 columns, use:<pre>
  +
:vertical resize 80
 
</pre><br />
  +
You can also change the width in increments. To change the width by increments of 5, use:<pre>
  +
:vertical resize +5
  +
:vertical resize -5
 
</pre><br />
   
  +
====== Split resizing ======
You can use <code>Ctrl-W +</code> and <code>Ctrl-W -</code> to resize a split window. For changing the width of a window, use <code>Ctrl-W &gt;</code> to increase the window size by one, while <code>Ctrl-W &lt;</code> decreases the window width by one. Those keys also accept a count, so that you can change the window size in larger steps, e.g. <code>10 Ctrl-W+</code> increases the window size by 10 lines.
+
For a '''split''' window: You can use <code>Ctrl-w +</code> and <code>Ctrl-w -</code> to resize the height of the current window by a single row. For a '''vsplit''' window: You can use <code>Ctrl-w &gt;</code> and <code>Ctrl-w &lt;</code> to resize the width of the current window by a single column. Additionally, these key combinations accept a count prefix so that you can change the window size in larger steps. (e.g. <code>Ctrl-w 10 +</code> increases the window size by 10 lines)
To resize all Windows to the same size, you can use <code>CTRL-W =</code> and to increase a window to its maximum size, use <code>Ctrl-W _</code>.
 
   
  +
To resize all windows to equal dimensions based on their splits, you can use <code>Ctrl-w =</code>.
To resize in different steps, you can create maps that will adjust the window size differently. For example to increase the window size by a factor of 1.5 and decrease the window size by 0.67, you can map this:
 
  +
<pre>
 
 
To increase a window to its maximum height, use <code>Ctrl-w _</code>.
  +
  +
To increase a window to its maximum width, use <code>Ctrl-w |</code>.
  +
 
To resize in different steps, you can create maps that will adjust the window size differently. For example to increase the window size by a factor of 1.5 and decrease the window size by 0.67, you can map this:<pre>
 
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
 
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
 
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
 
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
</pre>
+
</pre><br />
 
In Gvim and vim in terminals with mouse support, it is also possible to use the mouse to resize a window. Simply grab the statusline at the window border and drag it into the desired direction.
   
 
====== See also ======
Alternatively you can use the <code>:resize</code> command to change the height of the window, to change the window width, use the <code>:vertical </code> modifier. So to resize by 10 lines, use:
 
 
[[VimTip427]]
<pre>
 
:res +10
 
:res -10
 
</pre>
 
And to resize to a size of 20 use this:
 
<pre>
 
:res 20
 
:vertical resize 20
 
</pre>
 
   
 
====== Plugins ======
It is also possible to use the mouse to resize a window. Simply grab the statusline at the window border and drag it into the desired direction.
 
 
==See also==
 
*[[VimTip427]]
 
==Plugins==
 
 
The following plugins allow to define submodes, that make it possible to use e.g. <code>Ctrl-W +</code> to increase the window size and keep on increasing as long as you keep '+' pressed:
 
The following plugins allow to define submodes, that make it possible to use e.g. <code>Ctrl-W +</code> to increase the window size and keep on increasing as long as you keep '+' pressed:
  +
* Andy Wokulas {{script|id=2223|text=tinymode plugin}}
 
* Kana Natsunos {{script|id=2467|text=submode plugin}}
+
Andy Wokulas {{script|id=2223|text=tinymode plugin}}
  +
* Tom Links {{script|id=4199|text=tiny keymaps}}
 
 
Kana Natsunos {{script|id=2467|text=submode plugin}}
==Comments==
 
  +
 
Tom Links {{script|id=4199|text=tiny keymaps}}
  +
 
====== Comments ======

Latest revision as of 05:12, 24 August 2022

Tip 1215 Printable Monobook Previous Next

created April 26, 2006 · complexity basic · author Robert & Bill · version 7.0


This tip is about how to resize Windows efficiently.

Window resizing[]

You can use the :resize command or its shortcut :res to change the height of the window. To change the height to 60 rows, use:

:resize 60


You can also change the height in increments. To change the height by increments of 5, use:

:res +3.5
:res 4


You can use :vertical resize to change the width of the current window. To change the width to 80 columns, use:

:vertical resize 80


You can also change the width in increments. To change the width by increments of 5, use:

:vertical resize +5
:vertical resize -5


Split resizing[]

For a split window: You can use Ctrl-w + and Ctrl-w - to resize the height of the current window by a single row. For a vsplit window: You can use Ctrl-w > and Ctrl-w < to resize the width of the current window by a single column. Additionally, these key combinations accept a count prefix so that you can change the window size in larger steps. (e.g. Ctrl-w 10 + increases the window size by 10 lines)

To resize all windows to equal dimensions based on their splits, you can use Ctrl-w =.

To increase a window to its maximum height, use Ctrl-w _.

To increase a window to its maximum width, use Ctrl-w |.

To resize in different steps, you can create maps that will adjust the window size differently. For example to increase the window size by a factor of 1.5 and decrease the window size by 0.67, you can map this:

nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>


In Gvim and vim in terminals with mouse support, it is also possible to use the mouse to resize a window. Simply grab the statusline at the window border and drag it into the desired direction.

See also[]

VimTip427

Plugins[]

The following plugins allow to define submodes, that make it possible to use e.g. Ctrl-W + to increase the window size and keep on increasing as long as you keep '+' pressed:

Andy Wokulas tinymode plugin

Kana Natsunos submode plugin

Tom Links tiny keymaps

Comments[]