|
|
| (3 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| − |
{{review}} |
|
| |
{{TipImported |
|
{{TipImported |
| |
|id=1215 |
|
|id=1215 |
| Line 6: |
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= |
| |
}} |
|
}} |
| − |
You know that you can use "<c-w> +" and "<c-w> -" to resize a split window, but did you know you can repeat the resize commands (e.g. "10<c-w>+" will increase the window size by 10). |
|
| |
|
|
|
| − |
While this is a basic tip, I sometimes need to split windows in terminals and ended up killing my fingers while resizing them until I realized that the command could be repeated. |
+ |
This tip is about how to resize {{help|prefix=no|usr_08.txt|Windows}} efficiently. |
| − |
|
|
| − |
Other resizing tips are at [[VimTip427]]. |
|
| − |
|
|
| − |
==Comments== |
|
| − |
Here are some other suggestions. Increasing a window size by a factor of 1.5 and decreasing by a factor of 0.67 seems to work well for me. |
|
| |
|
|
|
| |
+ |
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> |
|
<pre> |
| − |
nnoremap <silent><Leader>= :<C-u>exe "norm! z".(line("$")<=winheight(0)?line("$")+&so:(winheight(0)+&so+1)*3/2)."\<lt>CR>"<CR> |
+ |
:resize 60 |
| − |
nnoremap <silent><Leader>- :<C-u>exe "norm! z".(winheight(0)*2/3)."\<lt>CR>"<CR> |
+ |
</pre> |
| − |
nnoremap <Leader>_ <C-w>_ |
+ |
You can also change the height in increments. To change the height by increments of 5, use: |
| − |
nnoremap <Leader><Bar> <C-w><Bar> |
+ |
<pre> |
| |
+ |
:res +5 |
| |
+ |
:res -5 |
| |
</pre> |
|
</pre> |
| |
|
|
|
| − |
---- |
|
| − |
You can also use the :resize command for this, e.g: |
|
| |
|
|
|
| |
+ |
You can use <code>:vertical resize</code> to change the width of the current window. To change the width to 80 columns, use: |
| |
<pre> |
|
<pre> |
| − |
:res +10 |
+ |
:vertical resize 80 |
| − |
:res -10 |
+ |
</pre> |
| − |
:res 20 |
+ |
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> |
|
</pre> |
| |
|
|
|
| − |
---- |
|
| − |
WinWalker has resizing as well as a lot of other stuff. I just uploaded another version. It's only for Vim 7, though. |
|
| |
|
|
|
| − |
---- |
+ |
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 ></code> and <code>Ctrl-w <</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>10 Ctrl-w +</code> increases the window size by 10 lines] |
| − |
I have reduced these mappings to (in my opinion the most compact form): |
|
| |
|
|
|
| |
+ |
To resize all windows to equal dimensions based on their splits, you can use <code>Ctrl-w =</code>. |
| |
+ |
|
| |
+ |
To increase a window to its maximum size, 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> |
|
<pre> |
| − |
nnoremap <silent> + :exe "resize " . (winheight(0) * 3/2)<CR> |
+ |
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR> |
| − |
nnoremap <silent> - :exe "resize " . (winheight(0) * 2/3)<CR> |
+ |
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR> |
| |
</pre> |
|
</pre> |
| |
|
|
|
| − |
---- |
|
| − |
You can also drag the split with the mouse to where you want it. Just grab ahold of the statusline that makes the split, and drag. I know this works at under Windows, both in GUI and in non-GUI. |
|
| |
|
|
|
| − |
It also works under Unix. I also like to use the "<c-w> =" to make all windows same size (once I've resized 10 subwindows and got lost on the original one I'm working on). "<c-w> _" (underscore) is very powerfull too, to maximize one subwindow |
+ |
In Gvim, 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]] |
| − |
I have happily created submodes for various window commands with this plugin http://www.vim.org/scripts/script.php?script_id=2467 It has some drawbacks that the submode name length is limited, you can't use spaces, but it makes resizing easier. |
+ |
==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: |
| |
+ |
* Andy Wokulas {{script|id=2223|text=tinymode plugin}} |
| |
+ |
* Kana Natsunos {{script|id=2467|text=submode plugin}} |
| |
+ |
* Tom Links {{script|id=4199|text=tiny keymaps}} |
| |
+ |
==Comments== |
This tip is about how to resize Windows efficiently.
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 +5
:res -5
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
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. 10 Ctrl-w + 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 size, 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, 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.
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: