Hi guys, I think I've found a bug in the way the cursor position is handled when undoing `:s/...` command. It's a bit of a long winded story, so please bear with me:
The way my VIM is set up, saving a buffer to a file triggers a custom StripTrailingSpaces() function, which is attached at the end of the StackOverflow question (http://goo.gl/ykwJDS): autocmd BufWritePre,FileWritePre,FileAppendPre,FilterWritePre <buffer> \ :keepjumps call UmkaDK#StripTrailingSpaces(0) After seeing "Restore the cursor position after undoing text change made by a script" vim tip (http://goo.gl/Gs3fqG), I got an idea to exclude the changes made by my function from the undo history by merging undo record created by the function onto the end of the previous change in the buffer. To validate my idea I've used this simple test case: set undolevels=10 normal ggiline one is full of aaaa set undolevels=10 " used to break a change into separate undo blocks normal Goline two is full of bbbb set undolevels=10 " used to break a change into separate undo blocks normal Goline three is full of cccc set undolevels=10 " used to break a change into separate undo blocks undojoin keepjumps %s/aaaa/zzzz/ normal u As you can see, after undoing the last change in the buffer, that is creating the third line, the cursor is correctly returned to the second line in the file. Since my test worked, I implemented an almost identical `undojoin` in my function (see http://goo.gl/ykwJDS). However, when I undo the last change after the function has run, the cursor is returned to the top most change in the file. This is often a stripped space and is *not* the position of the change I `undojoin`-ed to. @doliver, in one of the answers on StackOverflow (http://goo.gl/ykwJDS), has done a bit more debugging on this issue and it looks more and more like it might be a problem with the way vim records the change location when executing the `:s/...` command. However, if at all possible, I would really like someone a bit more knowledgable in the inner workings of vim to have a look at this. Thanks a lot, Dmytro -- -- 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.
