vsplit and split and having the working window always on top left

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

vsplit and split and having the working window always on top left

jose isaias cabrera-2

Ok Tony, let's see how good you are... :-)

You gave us this function,

>>
>> I don't use vertical split windows, yet. ;-)
>>
>> Thanks.
>
>For those who do, I think I found the solution:
>
>    function! WindowToMargin()
>        let i = 0
>        let j = winnr()
>        while j > i
>            wincmd r
>            let i = j
>            let j = winnr()
>        endwhile
>    endfunction
>    autocmd WinEnter * call WindowToMargin()
>
>If I didn't goof, this will move the current window to the top if all
>splits
>are horizontal, to the far left if all splits are vertical, and to the top
>or left of its row or column if mixing vertical and horizontal splits.

which works perfectly if all windows are vertical or horizontal.  But, if
they are mixed, then just the last call to split, be it vsplit or split,
will work, however, the other previous call will be ignore.  The idea is to
have all of them recycle, so that CTRL-w would change from (C=cursor)

w1 C |w2
     |
     |
---------
w3
---------
w4
---------

to

w2 C | w3
     |
     |
---------
w4
---------
w1
---------

Now, go ahead and work your magic. :-)

I had never used vsplit, but, after you sent this fix, I started playing
with it, and I am going to start using it.  It's not bad, specially when you
are looking at two files with subroutines that you are calling and want to
know what variables to pass and things of that nature.

Vim is the best editor ever!

thanks,

jos?

Reply | Threaded
Open this post in threaded view
|

Re: vsplit and split and having the working window always on top left

A.J.Mechelynck
----- Original Message -----
From: "jose isaias cabrera" <[hidden email]>
To: "Vim" <[hidden email]>
Sent: Monday, August 22, 2005 5:24 PM
Subject: vsplit and split and having the working window always on top left


>
> Ok Tony, let's see how good you are... :-)
>
> You gave us this function,
>
>>>
>>> I don't use vertical split windows, yet. ;-)
>>>
>>> Thanks.
>>
>>For those who do, I think I found the solution:
>>
>>    function! WindowToMargin()
>>        let i = 0
>>        let j = winnr()
>>        while j > i
>>            wincmd r
>>            let i = j
>>            let j = winnr()
>>        endwhile
>>    endfunction
>>    autocmd WinEnter * call WindowToMargin()
>>
>>If I didn't goof, this will move the current window to the top if all
>>splits
>>are horizontal, to the far left if all splits are vertical, and to the top
>>or left of its row or column if mixing vertical and horizontal splits.
>
> which works perfectly if all windows are vertical or horizontal.  But, if
> they are mixed, then just the last call to split, be it vsplit or split,
> will work, however, the other previous call will be ignore.  The idea is
> to have all of them recycle, so that CTRL-w would change from (C=cursor)
>
> w1 C |w2
>     |
>     |
> ---------
> w3
> ---------
> w4
> ---------
>
> to
>
> w2 C | w3
>     |
>     |
> ---------
> w4
> ---------
> w1
> ---------
>
> Now, go ahead and work your magic. :-)
>
> I had never used vsplit, but, after you sent this fix, I started playing
> with it, and I am going to start using it.  It's not bad, specially when
> you are looking at two files with subroutines that you are calling and
> want to know what variables to pass and things of that nature.
>
> Vim is the best editor ever!
>
> thanks,
>
> jos?

The above is as good as I can manage. Someone else wants to try? Go ahead.

Best regards,
Tony.