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

wish for `` in vim

Expand Messages
  • Gabriel Zachmann
    I would like to ask for a slight modification of what `` does in vim. Right now, it jumps back to the former position, and it places the new current line
    Message 1 of 3 , Feb 7, 2000
    • 0 Attachment
      I would like to ask for a slight modification of what `` does in vim.
      Right now, it jumps back to the former position,
      and it places the new current line usually in the center of the window.

      However, I think it would make sense to place the new current line
      at the same position within the window where it was before.

      Reason:
      I've got a little autocommand for HTML files,
      which jumps to the end of the file when saving it,
      inserts the current date,
      then jumps back (while vim saves the file).
      It works fine, except that after I've done :w
      the current line is somewhere else on the screen than before,
      which is a little bit irritating.

      I think this problem can be generalized: `` can be used often quite
      conveniently in some autocommand to jump back to the position where the
      cursor was before the autocommand was invoked.
      The idea is to hide from the user that an autocommand has been invoked.
      In order to not disturb the user, it would be nice if `` would also
      restore the position on the screen, not only the position in the file.

      By augmenting the "meaning" of `` a little bit, this problem could be
      solved elegantly, couldn't it?

      What do the developers think?

      Gab.

      PS:
      Of course, I am pretty sure that this could also be solved by a vim
      script -- but in this case it seems to me that the right place to solve
      it would be the `` command itself, because it would make things a
      little bit more consistent, IMHO.


      --
      /---------------------------------------------------------------------\
      | What if you slept? And what if, in your sleep, you dreamed? |
      | And what if, in your dream, you went to heaven and there plucked a |
      | strange and beautiful flower? And what if, when you awoke, |
      | you had the flower in your hand? Ah, what then? (Coleridge) |
      | |
      | mailto:zach@... __@/' mailto:Gabriel.Zachmann@... |
      | http://www.igd.fhg.de/~zach |
      \---------------------------------------------------------------------/
    • Zdenek Sekera
      ... Having observed the same problem I can only agree with Gabriel s suggestion. I think it would make sense.
      Message 2 of 3 , Feb 8, 2000
      • 0 Attachment
        Gabriel Zachmann wrote:
        >
        > I would like to ask for a slight modification of what `` does in vim.
        > Right now, it jumps back to the former position,
        > and it places the new current line usually in the center of the window.
        >
        > However, I think it would make sense to place the new current line
        > at the same position within the window where it was before.
        >

        Having observed the same problem I can only agree with Gabriel's
        suggestion. I think it would make sense.

        ---Zdenek
      • Bram Moolenaar
        ... You mean that the relative position of the cursor line in the window is remembered for the mark? Since the mark may have been set by a command that didn t
        Message 3 of 3 , Feb 9, 2000
        • 0 Attachment
          Gabriel Zachmann wrote:

          > I would like to ask for a slight modification of what `` does in vim.
          > Right now, it jumps back to the former position,
          > and it places the new current line usually in the center of the window.
          >
          > However, I think it would make sense to place the new current line
          > at the same position within the window where it was before.

          You mean that the relative position of the cursor line in the window is
          remembered for the mark? Since the mark may have been set by a command that
          didn't scroll the window, it would be strange if `` does scroll the window.

          Also, when `` jumps to a position which is already being displayed, it's
          strange that the text will scroll.

          > Reason:
          > I've got a little autocommand for HTML files,
          > which jumps to the end of the file when saving it,
          > inserts the current date,
          > then jumps back (while vim saves the file).
          > It works fine, except that after I've done :w
          > the current line is somewhere else on the screen than before,
          > which is a little bit irritating.
          >
          > I think this problem can be generalized: `` can be used often quite
          > conveniently in some autocommand to jump back to the position where the
          > cursor was before the autocommand was invoked.
          > The idea is to hide from the user that an autocommand has been invoked.
          > In order to not disturb the user, it would be nice if `` would also
          > restore the position on the screen, not only the position in the file.

          That can be fixed in another way, without changing the meaning of ``:

          save position: maHmb
          restore position: 'bzt`a

          > PS:
          > Of course, I am pretty sure that this could also be solved by a vim
          > script -- but in this case it seems to me that the right place to solve
          > it would be the `` command itself, because it would make things a
          > little bit more consistent, IMHO.

          But it would make `` incompatible with Vi and previous releases of Vim. Since
          there is another solution, I prefer to keep `` compatible.

          --
          The Characters and incidents portrayed and the names used are fictitious and
          any similarity to the names, characters, or history of any person is entirely
          accidental and unintentional.
          Signed RICHARD M. NIXON
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /-/-- Bram Moolenaar --- Bram@... --- http://www.moolenaar.net --\-\
          \ \ Vim: http://www.vim.org ICCF Holland: http://www.vim.org/iccf / /
        Your message has been successfully submitted and would be delivered to recipients shortly.