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

54901Re: Windows gvim doesn't properly update cursor position following an imap

Expand Messages
  • Gary Johnson
    Sep 2, 2009
    • 0 Attachment
      On 2009-09-01, Gary Johnson wrote:
      > To observe this problem, start gvim from a Windows Command Prompt as
      > gvim -N -u NONE -U NONE
      > then define this mapping:
      > imap ,= <Esc>0y$!!echo d<CR>I = <Esc>0PA
      > Enter insert mode on a empty line and type
      > abc
      > followed by
      > ,=
      > to trigger the mapped operation. You will see this line with the
      > cursor positioned between the b and the c.
      > abc = d
      > This is incorrect: the cursor should be immediately to the right of
      > the d. At this point, type some letter, say x, and the cursor will
      > jump to the right so that you will see this:
      > abc = d x
      > with the cursor immediately to the right of the x. This is also
      > incorrect: there should be no space between the d and the x.
      > I first observed this problem using gvim 7.2.148 on Windows XP. I
      > just updated to 7.2.245 from the Cream site and the results are the
      > same.
      > The DOS version of vim 7.2.245 has only the second bug, the extra
      > space. It (almost) correctly puts the cursor to the right of that
      > extra space following the d as soon as the mapping is executed.
      > Neither problem appears in Cygwin's package of vim 7.2 nor in a vim
      > 7.2.148 I built on Linux. I have not tried gvim on Linux to see if
      > the problem is there.

      I've done a little more experimenting with this and have discovered
      two things. First, I can work around the problem by adding a redraw
      command to the end of the mapping,

      imap ,= <Esc>0y$!!echo d<CR>I = <Esc>0PA<C-O><C-L>

      Second, the spurious space at the end of the line appears to be an
      artifact of Windows' echo. If I use some other command there, such
      as UnxUtils' grep, there is no extra space. I had chosen echo in
      place of the command I use in the actual mapping, nickle, to make
      the first problem easier for others to replicate.

      I should add, too, that this redrawing problem doesn't appear if one
      types the rhs of the mapping--it only happens if those commands are
      executed by typing the lhs of the mapping.

      I also verified that the problem does not occur using gvim 7.2.148
      on Linux. The problem appears only on the Windows GUI version of


      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 2 messages in this topic