Vim更改列表行为

时间:2014-11-14 09:44:30

标签: vim changelist

我试图在vim上查看更改列表,但我无法理解以下行为:

例如,我插入以下文字:

I like chips and fish.

意识到我的命名错误,所以我想得到:

I like fish and chips.

从没有.vimrc(vim -u NONE)的新vim实例开始,这正是我所做的(#仅用于解释):

iI like chips and fish.<Esc>  # Insert text. Realize I want to switch the words
Fc                            # Jump back to 'chips'
de                            # Delete the word (and put it in anon register)
ff                            # Jump to the 'fish' word
vep                           # Select the word, and paste from anon register
g;                            # Try to jump back to the position where I change
                              # the word 'chips'. It doesn't work and I get:
E19: Mark has invalid line number

# To see what is going on i print the change list:
:changes
    change line  col text
        2     1   12 I like  and chips.
        1     2   12 -invalid-
    >

我的第一个问题是为什么跳跃首先没有起作用?

其次,更改列表的-invalid-条目对我没有任何意义。如你所见,我从未超越第1行。为什么第2行有一个条目?

我正在使用Vim 7.4.52

更新: -invalid-似乎是一个错误。我已经报告过了:

https://code.google.com/p/vim/issues/detail?id=283

1 个答案:

答案 0 :(得分:1)

在Mac OS X上的默认Vim(7.3没有GUI的普通版本,没有补丁),g;将光标移动到c中的chips和{{1}的输出与你的不同:

:changes

仅记住一个更改的事实与change line col text > 0 1 16 I like fish and chops.

中的此段落一致
:help g;

所以一切正常(如果有点令人惊讶)。

使用合理最近的MacVim(7.4.258),我得到了您为When two undo-able changes are in the same line and at a column position less than 'textwidth' apart only the last one is remembered. This avoids that a sequence of small changes in a line, for example "xxxxx", adds many positions to the change list. When 'textwidth' is zero 'wrapmargin' is used. When that also isn't set a fixed number of 79 is used. Detail: For the computations bytes are used, not characters, to avoid a speed penalty (this only matters for multi-byte encodings). 描述的行为和略微不同的g;输出(&#34; fish&# 34;你的遗失了):

:changes

它闻起来很多,就像你发现了一个错误,我强烈建议你通知the vim_dev mailing list它(如果他们还不知道的话)。