how to resize window continuously ?

234 views
Skip to first unread message

stardiviner

unread,
Jun 5, 2012, 9:18:08 PM6/5/12
to Vim.use.G
In vim, how to adjust window height or width continuously ?
For example,
press `C-w -` and `-` and `-` to decrease window height again and again,
But this seems can not work in Vim.

So is there a good and simple way to do this ?
--
[ stardiviner ] ^^&^^ {I hate all of you ! Leave me alone}
IRC(freenode): stardiviner \\ Twitter: @numbchild \\
GnuPG Key fingerprint
>>> 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
signature.asc

Tim Chase

unread,
Jun 5, 2012, 9:25:41 PM6/5/12
to Vim.use.G
On 06/05/12 20:18, stardiviner wrote:
> In vim, how to adjust window height or width continuously ?
> For example,
> press `C-w -` and `-` and `-` to decrease window height again and again,
> But this seems can not work in Vim.
>
> So is there a good and simple way to do this ?

I suppose I'd just create a mapping:

:nnoremap - <c-w>-
:nnoremap + <c-w>+

and then you can repeatedly hit +/- to increase/decrease the window
size. The "+" can be shadowed uneventfully as <cr> also provides
the same functionality. Shadowing "-" does lose functionality, but
it's almost never used (perhaps outside of vimgolf) and could be
remapped to another key.

-tim



stardiviner

unread,
Jun 5, 2012, 9:52:58 PM6/5/12
to Vim.use.G
signature.asc

Ben Fritz

unread,
Jun 5, 2012, 10:32:29 PM6/5/12
to vim...@googlegroups.com
On Tuesday, June 5, 2012 8:18:08 PM UTC-5, miles christopher wrote:
> In vim, how to adjust window height or width continuously ?
> For example,
> press `C-w -` and `-` and `-` to decrease window height again and again,
> But this seems can not work in Vim.
>
> So is there a good and simple way to do this ?

Use the mouse. Really; I think re-sizing windows is the single best use for Vim's mouse support.

Thilo Six

unread,
Jun 6, 2012, 5:39:23 AM6/6/12
to vim...@googlegroups.com
Hello Ben,


Excerpt from Ben Fritz:

-- <snip> --
>> press `C-w -` and `-` and `-` to decrease window height again and again,
>> But this seems can not work in Vim.
>>
>> So is there a good and simple way to do this ?
>
> Use the mouse. Really; I think re-sizing windows is the single best use for Vim's mouse support.

Resizing windows with the mouse only works in GVim though. In console Vim you
have to use ':resize' or the already mentioned approach.


--
Regards,
Thilo

4096R/0xC70B1A8F
721B 1BA0 095C 1ABA 3FC6 7C18 89A4 A2A0 C70B 1A8F


Ben Fritz

unread,
Jun 6, 2012, 10:29:05 AM6/6/12
to vim...@googlegroups.com
On Wednesday, June 6, 2012 4:39:23 AM UTC-5, Thilo Six wrote:
> Hello Ben,
>
>
> Excerpt from Ben Fritz:
>
> -- <snip> --
> >> press `C-w -` and `-` and `-` to decrease window height again and again,
> >> But this seems can not work in Vim.
> >>
> >> So is there a good and simple way to do this ?
> >
> > Use the mouse. Really; I think re-sizing windows is the single best use for Vim's mouse support.
>
> Resizing windows with the mouse only works in GVim though. In console Vim you
> have to use ':resize' or the already mentioned approach.
>

Not quite true, some terminals support it:


*'mouse'* *E538*
'mouse' string (default "", "a" for GUI, MS-DOS and Win32)
global
{not in Vi}
Enable the use of the mouse. Only works for certain terminals
(xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
sysmouse and Linux console with gpm). For using the mouse in the
GUI, see |gui-mouse|.

Actually, every time I've actually used Vim in a console, it worked just fine.

Thilo Six

unread,
Jun 6, 2012, 11:44:51 AM6/6/12
to vim...@googlegroups.com
Hello Ben,


Excerpt from Ben Fritz:
-- <snip> --
>> Resizing windows with the mouse only works in GVim though. In console Vim you
>> have to use ':resize' or the already mentioned approach.
>>
>
> Not quite true, some terminals support it:
>
>
> *'mouse'* *E538*
> 'mouse' string (default "", "a" for GUI, MS-DOS and Win32)
> global
> {not in Vi}
> Enable the use of the mouse. Only works for certain terminals
> (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
> sysmouse and Linux console with gpm). For using the mouse in the
> GUI, see |gui-mouse|.
>
> Actually, every time I've actually used Vim in a console, it worked just fine.

cough 'set mouse' that reminds me of something.
:set mouse?
mouse=vh

Ooops. I must have this setting for so many years now that i totally forgotten
about it. Probably because i accidentally hit the mouse too many times which
brought me away from where i wanted to be.
True with a non broken mouse setting it works like charm.

Now if someone knows a doctor for shooting one self in the foot.....

John Little

unread,
Jun 6, 2012, 11:51:42 PM6/6/12
to vim...@googlegroups.com
On Thursday, June 7, 2012 3:44:51 AM UTC+12, Thilo Six wrote:

> Now if someone knows a doctor for shooting one self in the foot.....

The Americans have a medicine for it, they call it "humble pie". Seem to have a lot to spare... ;)

Andy Wokula

unread,
Jul 11, 2012, 1:33:24 PM7/11/12
to vim...@googlegroups.com
Am 06.06.2012 03:18, schrieb stardiviner:
> In vim, how to adjust window height or width continuously ?
> For example,
> press `C-w -` and `-` and `-` to decrease window height again and again,
> But this seems can not work in Vim.
>
> So is there a good and simple way to do this ?

There is a way:

set timeoutlen=3000 " 1 second times out too soon
set showcmd " mode prefix in lower right corner

nmap <C-W>+ <C-W>+<SID>winheight
nmap <C-W>- <C-W>-<SID>winheight
nn <script> <SID>winheight+ <C-W>+<SID>winheight
nn <script> <SID>winheight- <C-W>-<SID>winheight
nmap <SID>winheight <Nop>

See also submode and tinymode.vim (the latter by me).

--
Andy

chris

unread,
Jul 11, 2012, 9:16:35 PM7/11/12
to vim...@googlegroups.com
Excerpts from [ Andy Wokula ] //// On [2012-07-11 19:33:24 +0200]:
This one is better. Also how to use this way to adjust window width ?

> --
> Andy

> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
signature.asc

Christian Brabandt

unread,
Jul 12, 2012, 2:05:49 AM7/12/12
to vim...@googlegroups.com
This doesn't do anything for me, except displaying _winheight in the
lower right corner.

regards,
Christian

Andy Wokula

unread,
Jul 12, 2012, 4:19:47 AM7/12/12
to vim...@googlegroups.com
Yes, `_winheight' is from the incomplete <SID>winheight mapping.

So after :split and `<C-W> -' you type another `-' and the window
doesn't change its size?

--
Andy

Andy Wokula

unread,
Jul 12, 2012, 4:20:30 AM7/12/12
to vim...@googlegroups.com
Am 12.07.2012 03:16, schrieb chris:
> Excerpts from [ Andy Wokula ] //// On [2012-07-11 19:33:24 +0200]:
>
>> Am 06.06.2012 03:18, schrieb stardiviner:
>>> In vim, how to adjust window height or width continuously ?
>>> For example,
>>> press `C-w -` and `-` and `-` to decrease window height again and again,
>>> But this seems can not work in Vim.
>
>>> So is there a good and simple way to do this ?
>
>> There is a way:
>
>> set timeoutlen=3000 " 1 second times out too soon
>> set showcmd " mode prefix in lower right corner
>
>> nmap<C-W>+<C-W>+<SID>winheight
>> nmap<C-W>-<C-W>-<SID>winheight
>> nn<script> <SID>winheight+<C-W>+<SID>winheight
>> nn<script> <SID>winheight-<C-W>-<SID>winheight
>> nmap<SID>winheight<Nop>
>
>> See also submode and tinymode.vim (the latter by me).
> This one is better. Also how to use this way to adjust window width ?

In the same way:


set timeoutlen=3000 " 1 second is too short
set showcmd " mode prefix in lower right corner

nmap <C-W>+ <C-W>+<SID>winsize
nmap <C-W>- <C-W>-<SID>winsize
nmap <C-W>< <C-W><<SID>winsize
nmap <C-W>> <C-W>><SID>winsize
nn <script> <SID>winsize+ <C-W>+<SID>winsize
nn <script> <SID>winsize- <C-W>-<SID>winsize
nn <script> <SID>winsize< 5<C-W><<SID>winsize
nn <script> <SID>winsize> 5<C-W>><SID>winsize
nmap <SID>winsize <Nop>


Tinymode also includes a mode for this purpose (with some extras).

--
Andy

Christian Brabandt

unread,
Jul 12, 2012, 4:52:02 AM7/12/12
to vim...@googlegroups.com
Oh yes, it does. I somehow thought, the Vim frame window should change
the size not the window within Vim.

regards,
Christian

ping

unread,
Jul 12, 2012, 11:17:30 PM7/12/12
to vim...@googlegroups.com
On 7/11/2012 9:16 PM, chris wrote:
> Excerpts from [ Andy Wokula ] //// On [2012-07-11 19:33:24 +0200]:
>
>> Am 06.06.2012 03:18, schrieb stardiviner:
>>> In vim, how to adjust window height or width continuously ?
>>> For example,
>>> press `C-w -` and `-` and `-` to decrease window height again and again,
>>> But this seems can not work in Vim.
>
>>> So is there a good and simple way to do this ?
>
>> There is a way:
>
>> set timeoutlen=3000 " 1 second times out too soon
>> set showcmd " mode prefix in lower right corner
>
>> nmap <C-W>+ <C-W>+<SID>winheight
>> nmap <C-W>- <C-W>-<SID>winheight
>> nn <script> <SID>winheight+ <C-W>+<SID>winheight
>> nn <script> <SID>winheight- <C-W>-<SID>winheight
>> nmap <SID>winheight <Nop>
>
>> See also submode and tinymode.vim (the latter by me).
> This one is better. Also how to use this way to adjust window width ?
>
>> --
>> Andy
>
>> --
>> You received this message from the "vim_use" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visit http://www.vim.org/maillist.php
>


is that so complicated? I use this in my vimrc:

map <C-left> zH
map <C-right> zL

so ctrl+left/right will contineously move right margin of curr window
left/right.

ping

unread,
Jul 12, 2012, 11:21:02 PM7/12/12
to vim...@googlegroups.com
sorry , typed the wrong thing:

nnoremap <S-right> <ESC><c-w>>
"map <S-left> <ESC>gT<CR>
nnoremap <S-left> <ESC><c-w><
nnoremap <S-up> <ESC><c-w>+
nnoremap <S-down> <ESC><c-w>-

here it is:
so shift+right/left/up/down do the work.

regards
ping
Reply all
Reply to author
Forward
0 new messages