3

vim で変更リストを取得しようとしていますが、次の動作を理解するのに苦労しています:

例として、次のテキストを挿入します。

I like chips and fish.

名詞の順序が間違っていることに気付いたので、取得したいのは次のとおりです。

I like fish and chips.

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

私の最初の質問は、そもそもなぜジャンプが機能しなかったのかということです。

第二に-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 (GUI なしの 7.3 通常バージョン、パッチなし) ではg;、カーソルがcinに移動しchips、出力は:changesあなたのものとは異なります。

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

変更が1 つだけ記憶されているという事実は、次の段落と一致しています。: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 に答える