简体   繁体   English

Vim更改列表行为

[英]Vim change list behaviour

I'm trying to grok the change list on vim and I'm having trouble understanding the following behavior: 我试图查看vim上的更改列表,但无法理解以下行为:

As example I insert the following text: 作为示例,我插入以下文本:

I like chips and fish.

Realized I got the nouns in the wrong order, so I want to get: 意识到我以错误的顺序获得了名词,所以我想得到:

I like fish and chips.

Starting with a fresh vim instance with no .vimrc ( vim -u NONE ) this is exactly what I do (# are just for explanation): 从没有.vimrc的新鲜vim实例开始( vim -u NONE ),这正是我要做的(#仅用于说明):

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

My first question is why the jump didn't work in the first place? 我的第一个问题是,为什么跳跃首先没有起作用?

Second, the -invalid- entry of the change list doesn't make any sense to me. 其次,更改列表的-invalid-条目对我来说没有任何意义。 As you saw I never went beyond line 1. Why is an entry with line 2? 如您所见,我从未超出第1行。为什么有第2行的条目?

Im using Vim 7.4.52 我正在使用Vim 7.4.52

Update: The -invalid- seems to be a bug. 更新: -invalid-似乎是一个错误。 I already reported it: 我已经报告了它:

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

In the default Vim on Mac OS X (7.3 Normal version without GUI, no patches), g; 在Mac OS X上的默认Vim(7.3普通版,无GUI,无补丁)中, g; moves the cursor to the c in chips and the output of :changes is different from yours: 将光标移至chipsc:changes的输出与您的不同:

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

The fact that only one change is remembered is consistent with this paragraph from :help g; 只记住一个更改的事实与:help g;这一段一致: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).

so everything is normal (if a bit surprising). 因此一切正常(如果有些意外)。

With a reasonably recent MacVim (7.4.258), I get the behavior you describe for g; 使用相当近期的MacVim(7.4.258),我得到了您描述的g;行为g; and a slightly different :changes output ("fish" is missing in yours): :changes输出略有不同(您的“缺少”鱼):

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

It smells a lot like you discovered a bug and I strongly suggest you notify the vim_dev mailing list about it (if they are not already aware). 它闻起来很像你发现一个错误,我强烈建议你通知了vim_dev邮件列表它(如果他们还不知道)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM