Control A Window

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

Control A Window

jason heddings-2
Hello-

I am trying to create an auto command that will automatically reposition a
visible window to the last line of the file it is displaying.  It would be
great if there was a way to just send some keys to a window.

Here's my setup:
I am editing a file in a window with a smaller preview window displaying
file contents.  Whenever my preview changes, I would like it to
automatically reposition to the bottom of the file it is showing, without
losing focus in the window I am editing.

Thanks,
--jah


Reply | Threaded
Open this post in threaded view
|

Re: Control A Window

A.J.Mechelynck
jason heddings wrote:

> Hello-
>
> I am trying to create an auto command that will automatically reposition a
> visible window to the last line of the file it is displaying.  It would be
> great if there was a way to just send some keys to a window.
>
> Here's my setup:
> I am editing a file in a window with a smaller preview window displaying
> file contents.  Whenever my preview changes, I would like it to
> automatically reposition to the bottom of the file it is showing, without
> losing focus in the window I am editing.
>
> Thanks,
> --jah


Well, the command to go to the last line is :$ (from the context of the
preview window). You may go to the preview window then use

        $
        wincmd p

where :wincmd p (equivalent to the Normal-mode command ^Wp) returns to
the previous (last-accessed) window.

But how do you detect that these commands need to be issued?

Assuming that you have a "true" preview window (in the Vim sense of
"preview") and that the cursor refresh must be triggered by
SomeEventName, the autocommand

        au SomeEventName * wincmd P | exec "$" | wincmd p

will do the refresh you want.


HTH,
Tony.

Reply | Threaded
Open this post in threaded view
|

RE: Control A Window

jason heddings-2
Thanks for the tip...  I think that this will get me closer.

I'm trying to set an autocommand on the FileChangedShell event.  It appears
to work the first time (on the first noticed change in the file), but when
the file changes after that, the window is not repositioned.  There is a
note in the doc that states "The commands must not change the current
buffer, jump to another buffer or delete a buffer."  This sounds like I may
not be able to do it in this fashion.

Here's the autocommand I was trying...  Any thoughts on getting it to work?
autocmd FileChangedShell <name_of_file> wincmd P | execute "$" | wincmd p

I've tried setting my verbose up to watch the commands, but when I refocus
on the window, something very quickly flashes and then is gone.

Thanks!
--jah


-----Original Message-----
From: A. J. Mechelynck [mailto:[hidden email]]
Sent: Sunday, 02 October, 2005 14:27
To: jason heddings
Cc: [hidden email]
Subject: Re: Control A Window

jason heddings wrote:
> Hello-
>
> I am trying to create an auto command that will automatically
> reposition a visible window to the last line of the file it is
> displaying.  It would be great if there was a way to just send some keys
to a window.
>
> Here's my setup:
> I am editing a file in a window with a smaller preview window
> displaying file contents.  Whenever my preview changes, I would like
> it to automatically reposition to the bottom of the file it is
> showing, without losing focus in the window I am editing.
>
> Thanks,
> --jah


Well, the command to go to the last line is :$ (from the context of the
preview window). You may go to the preview window then use

        $
        wincmd p

where :wincmd p (equivalent to the Normal-mode command ^Wp) returns to the
previous (last-accessed) window.

But how do you detect that these commands need to be issued?

Assuming that you have a "true" preview window (in the Vim sense of
"preview") and that the cursor refresh must be triggered by SomeEventName,
the autocommand

        au SomeEventName * wincmd P | exec "$" | wincmd p

will do the refresh you want.


HTH,
Tony.



Reply | Threaded
Open this post in threaded view
|

Re: Control A Window

A.J.Mechelynck
jason heddings wrote:

> Thanks for the tip...  I think that this will get me closer.
>
> I'm trying to set an autocommand on the FileChangedShell event.  It appears
> to work the first time (on the first noticed change in the file), but when
> the file changes after that, the window is not repositioned.  There is a
> note in the doc that states "The commands must not change the current
> buffer, jump to another buffer or delete a buffer."  This sounds like I may
> not be able to do it in this fashion.
>
> Here's the autocommand I was trying...  Any thoughts on getting it to work?
> autocmd FileChangedShell <name_of_file> wincmd P | execute "$" | wincmd p
>
> I've tried setting my verbose up to watch the commands, but when I refocus
> on the window, something very quickly flashes and then is gone.
>
> Thanks!
> --jah

Have you tried ":messages" to try and see whatever it was that flashed
by so quickly? It may or may not work, but at least you could try; do it
immediately after the flashing display, because the message list size is
fixed at 20.


Best regards,
Tony.