3

我正在尝试了解 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

4

1 回答 1

2

在 Mac OS X 上的默认 Vim(7.3 普通版,无 GUI,无补丁)中,g;将光标移动到cinchips并且输出与:changes您的不同:

change line  col text
>   0     1   16 I like fish and chops.

仅记住一个更改的事实与本段一致:help g;

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).

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

使用相当新的 MacVim(7.4.258),我得到了你描述的行为g;稍微不同的:changes输出(你的中缺少“鱼”):

change line  col text
    1     1   16 I like fish and chips.
>   0     2   16 -invalid-

它闻起来很像你发现了一个错误,我强烈建议你通知vim_dev 邮件列表(如果他们还不知道的话)。

于 2014-11-14T10:14:55.267 回答