Thursday, May 13, 2010

Re: Broken undo?

On 13/05/10 09:38, Israel Chauca F. wrote:
> Hi there,
>
> I found the following, open vim and do the following:
>
> - Insert 1 and exit insert mode.
> - Append 2 and then<C-R>=setline('.', '123')<CR> to add one char to the right of the cursor.
> - Without leaving insert mode, type other<CR> and the number 4, now exit insert mode.
> - Press u.
>
> I should expect to have just the number 1 in the window, but I'm left with two lines:
>
> 1
> 43
>
> If I undo again, I get the original empty window.
>
> If I start in the second step, I can't undo to the empty window, I'm left with two lines but I can exit vim as if the buffer was in its original state.
>
> Is that the expected behaviour or there is something wrong? why does the setline() call +<CR> affects the first edit?
>
> Thanks!
> Israel
>
>
>
>

In 'compatible' mode (including, by default, when you start Vim with no
vimrc, or with the -u command-line switch in order to use a nonstandard
vimrc), repeatedly hitting u alternates between the two latest states of
the buffer (this is vi-compatible "undoable undo").

In 'nocompatible' mode, including when Vim has found a .vimrc or a
_vimrc, repeatedly hitting u goes progressively backwards in time, up to
'undolevels' times. In that case, CTRL-R (in Normal mode) redoes what
had been undone.

See
:help 'undolevels'
:help undo-two-ways


Best regards,
Tony.
--
Cold, adj.:
When the politicians walk around with their hands in their own
pockets.

--
You received this message from the "vim_use" 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

No comments: