Christian Brabandt wrote:
> Hi Ingo!
>
> On Mo, 26 Mai 2014, Ingo Karkat wrote:
>
> > Hello Vim developers,
> >
> > I have a custom surround function that basically does this:
> >
> > let save_cursor = getpos('.')
> > execute "normal! eaXY\<Esc>"
> > call setpos('.', save_cursor)
> >
> > And this correctly restores the cursor to the original position. But
> > when I move down a line (with "j", same with "k" btw.) immediately after
> > triggering this, the cursor jumps to the column of the last insert (the
> > "Y" in the example above). This does not happen when:
> > - a (no-op) move within the same line is performed (e.g. "l" followed by
> > "h") before the "j"
> > - cursor() is used instead of setpos('.')
> >
> > I can reproduce this down to Vim version 7.0. Interestingly, in Vim
> > 7.0.000, the cursor() function is also affected, but that starts working
> > in Vim 7.1.000. I see this in the latest Vim 7.4.307 (HUGE build) on
> > Linux/x64, as well as Vim 7.4.264 on Windows/x64.
> >
> > You can reproduce this with the attached scriptlet:
> >
> > $ vim -N -u NONE -S bug-cursor-j.vim
> >
> > Or by executing this in the middle of some text:
> >
> > let save_cursor = getpos('.')|execute "normal! eaXY\<Esc>"|call
> > setpos('.', save_cursor)|normal! j
> >
> > The problematic call incorrectly positions the cursor (represented by |)
> > on the last insert column, instead of the column of the "B" where the
> > function was triggered:
> >
> > QuickBrownFoxJumpsOverMe |he he
> > Quick|BrownFoxJumpsOverMe he he
>
> This has been discussed before:
> https://groups.google.com/d/msg/vim_dev/xTa0kHWkY_o/ZXDq-HCifWsJ
> https://groups.google.com/d/msg/vim_dev/o9GRXaJMwHg/9g8INNnNB9YJ
>
> As suggested by ZyX in one of the threads, here is a patch, that allows
> to explicitly set curswant by enhancing the winrestview() function call.
>
> This means, you have to add an additional call to winrestview() like
> this:
> :call winrestview({'curswant':5})
> to make Vim request to stay in column *6* on vertical movement. Yes,
> there is a difference between the column number getpos() and
> winsaveview() returns.
This patch has drifted way down in the todo list. I'll move it up.
--
hundred-and-one symptoms of being an internet addict:
210. When you get a divorce, you don't care about who gets the children,
but discuss endlessly who can use the email address.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.