[prev in list] [next in list] [prev in thread] [next in thread]
List: vim
Subject: Re: g_ behaves like $ in visual mode
From: Bram Moolenaar <Bram () moolenaar ! net>
Date: 2003-08-29 20:24:04
[Download RAW message or body]
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@Moolenaar.net -- 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 ///
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic