Loading ...
Sorry, an error occurred while loading the content.

Control A Window

Expand Messages
  • jason heddings
    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
    Message 1 of 4 , Oct 1, 2005
    • 0 Attachment
      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
    • A. J. Mechelynck
      ... 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
      Message 2 of 4 , Oct 2, 2005
      • 0 Attachment
        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.
      • jason heddings
        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
        Message 3 of 4 , Oct 3, 2005
        • 0 Attachment
          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:antoine.mechelynck@...]
          Sent: Sunday, 02 October, 2005 14:27
          To: jason heddings
          Cc: vim@...
          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.
        • A. J. Mechelynck
          ... 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
          Message 4 of 4 , Oct 3, 2005
          • 0 Attachment
            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.
          Your message has been successfully submitted and would be delivered to recipients shortly.