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

Re: g_ behaves like $ in visual mode

Expand Messages
  • Bram Moolenaar
    ... Yes, this is a bug. The code doesn t take care of moving backwards from the NUL after the end of the line. This patch should fix it: ... ***************
    Message 1 of 1 , Aug 29, 2003
    • 0 Attachment
      Jean-Rene David wrote:

      > On the following line:
      >
      > Is that a bug?
      >
      > 'g_' moves to the '?' when in normal mode but moves
      > to the end of the line (including the newline
      > caracter) when in visual mode. '$' already does
      > that in visual mode so I would've thought 'g_'
      > would move to the last non-blank even in visual
      > mode.
      >
      > :h g_
      >
      > Anyone?

      Yes, this is a bug. The code doesn't take care of moving backwards from
      the NUL after the end of the line. This patch should fix it:

      *** ../vim-6.2.071/src/normal.c Mon Jun 2 22:20:28 2003
      --- src/normal.c Fri Aug 29 20:53:57 2003
      ***************
      *** 6984,6989 ****
      --- 6986,6996 ----
      {
      char_u *ptr = ml_get_curline();

      + /* In Visual mode we may end up after the line. */
      + if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL)
      + --curwin->w_cursor.col;
      +
      + /* Decrease the cursor column until it's on a non-blank. */
      while (curwin->w_cursor.col > 0
      && vim_iswhite(ptr[curwin->w_cursor.col]))
      --curwin->w_cursor.col;


      --
      This sentence is not sure that it exists, but if it does, it will
      certainly consider the possibility that other sentences exist.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.