Setting The Window Position

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

Setting The Window Position

jason heddings-2
Hello-

Is it possible to set the window position to something beyond the end of the
file?

I would like to be able to set the window position such that the last line
is in the middle of my window.  Is this possible?  I have tried things like
"cursor(line('$')+5, 0)" but that doesn't seem to work (obviously, there's
no line there).

Thanks!
--jah

Reply | Threaded
Open this post in threaded view
|

Re: Setting The Window Position

Wes Potts
In normal mode, the following command works for me.
Gzz

I do not know if you can use this (or something similar in a script).

Wes

On 10/4/05, jason heddings <[hidden email]> wrote:

> Hello-
>
> Is it possible to set the window position to something beyond the end of the
> file?
>
> I would like to be able to set the window position such that the last line
> is in the middle of my window.  Is this possible?  I have tried things like
> "cursor(line('$')+5, 0)" but that doesn't seem to work (obviously, there's
> no line there).
>
> Thanks!
> --jah
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Setting The Window Position

A.J.Mechelynck
In reply to this post by jason heddings-2
jason heddings wrote:

> Hello-
>
> Is it possible to set the window position to something beyond the end of the
> file?
>
> I would like to be able to set the window position such that the last line
> is in the middle of my window.  Is this possible?  I have tried things like
> "cursor(line('$')+5, 0)" but that doesn't seem to work (obviously, there's
> no line there).
>
> Thanks!
> --jah
>
>
>
>

        Gz.

In a script: "normal Gz." (without the quotes).

G move cursor to last line
z. move current line to center of window


It is possible to set the window position such that the first line of
the window coincides with any line in the file (even the last one). It
is (AFAIK) _not_ possible to have the cursor on a non-displayed line (a
line outside the window scope), or below the end of the file. So you can
move the bottom line of the file as far up as the top line of the window
provided that you accept that the cursor be on it.


HTH,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Setting The Window Position

A.J.Mechelynck
f3l wrote:
> On 10/4/05, A. J. Mechelynck <[hidden email]> wrote:
[...]
>>         Gz.
>>
>
> on my box that doesnt work,
> however Gzz does, is that a bug?
>
[...]

Maybe. What version (and, for 6.3 and lower, patchlevel if any) are you
using? Mine is:

VIM - Vi IMproved 7.0aa ALPHA (2005 Oct 4, compiled Oct  4 2005 13:24:27)
MS-Windows 32 bit GUI version with OLE support
Compiled by [hidden email]
Big version with GUI.  Features included (+) or not (-):

etc. (See full ":version" listing as
http://users.skynet.be/antoine.mechelynck/vim/v7gvim.txt ).


Its help mentions that zz and z. are the same except one of them keeps
the cursor column unchanged and the other moves to the leftmost nonblank.


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re [2]: Setting The Window Position

A.J.Mechelynck
A. J. Mechelynck wrote:

> f3l wrote:
>> On 10/4/05, A. J. Mechelynck <[hidden email]> wrote:
> [...]
>>>         Gz.
>>>
>> on my box that doesnt work,
>> however Gzz does, is that a bug?
>>
> [...]
>
> Maybe. What version (and, for 6.3 and lower, patchlevel if any) are you
> using? Mine is:
>
> VIM - Vi IMproved 7.0aa ALPHA (2005 Oct 4, compiled Oct  4 2005 13:24:27)
> MS-Windows 32 bit GUI version with OLE support
> Compiled by [hidden email]
> Big version with GUI.  Features included (+) or not (-):
>
> etc. (See full ":version" listing as
> http://users.skynet.be/antoine.mechelynck/vim/v7gvim.txt ).
>
>
> Its help mentions that zz and z. are the same except one of them keeps
> the cursor column unchanged and the other moves to the leftmost nonblank.
>
>
> Best regards,
> Tony.

P.S. The command you tried, and which didn't work, was Gz.
(gee-zed-dot), wasn't it, not just Gz (gee-zed)?


Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

Re: Re [2]: Setting The Window Position

A.J.Mechelynck
f3l wrote:
[...]
> GZ, no dot
> obviously, i missed the dot,
> sorry
>
> it seems that you have to be extra-careful, when reading VIM posts.

Without the dot, your last command (z-something) isn't complete; Vim is
still waiting for input. If you have 'showcmd' set, there is a lone z at
bottom right of the screen showing the incomplete command.

Yes, you have to be extra-careful; for instance, if you enter GZZ
instead of Gzz Vim will write the current file if modified, close the
current window, and then (if that window was the only nonhelp window)
terminate. Not at all the same thing as moving the bottom of the file to
the middle of the window.


Best regards,
Tony.