On 7月17日, 上午10时31分, Ben Fritz <[email protected]> wrote:
> On Jul 15, 5:33 am, StarWing <[email protected]> wrote:
>
> > OKay, changenr() is more or less enough. but in doc, it says "After
> > undo it is one less than the number of the undone change."
>
> > so, how can I get the exactly serial number of current buffer? the one
> > I can use in undo command. (changenr() can't use in undo command, exec
> > changenr()."u" is not always current status of buffer).
>
> What do you mean changenr() can't be used in the undo command? It says
> right in the help that it can be! What exactly are you trying to do,
> and what do you get instead? What is the "serial number of current
> buffer"? Are you looking for :help changetick instead?
>
> You give an example trying to do :exec changenr()."u" Don't you
> want :exec "undo ".changenr()? It doesn't look like :undo takes a
> count...it takes an argument.

Thank you for attention my problem!!! :-)

first, my purpose is confirm the state of buffer. that's see, when I
press 'u<C-R>', '<C-R>u>', 'ifoobaru', 'g+g-', etc. we can know the
state of buffer is not change. so I can't use b:changetick...

then, the doc of changenr() said, when you do a undo, changenr() just
return the state number you are undo FORM substract 1, e.g. you are in
state 5, you press u and return to state 2, but changenr() doesn't
return 2, it returns 5-1 = 4! you can do a expriement:

1. input "ione<ESC>". (changenr() 1, state 1)
2. input "i too<ESC>". (changenr() 2, state 2)
3. input "u". (changenr() 1, state 1)
4. input "i two<esc>". (changenr() 3, state 3)
5. input "u" (changenr() 2, but state is 1)

so, I can't use changenr() for this purpose :-(

at last, in ex_cmds.h, undo item is just:

EX(CMD_undo,            "undo",         ex_undo,
                        RANGE|NOTADR|COUNT|ZEROR|TRLBAR|CMDWIN),

it can accept a count and even a range, but not NEEDARG. so maybe we
should update the doc undo.txt...

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui