vimdiffを使用して変更をコピーするための推奨方法は何ですか?

vimdiffを使用して変更をコピーするための推奨方法は何ですか?

私はファイルを比較してソースコードリポジトリを更新するときにvimdiffを使うのが好きです。あるファイルの変更を別のファイルにコピーするには、通常、次のキーシーケンスを使用します。

Shift + V (select line)
k or j; { or }; Up or down arrow keys (select more lines)
y  (copy selected lines)
Ctrl + w, left/right arrow (move to other pane)
p (paste lines)

キーボードショートカットの対価であるVimは、同じことを行うより簡単な方法を持っている必要があります。それを持って?ソースコードの変更を手動で更新するには何を使用しますか?

ベストアンサー1

do(diff acquire)とdp(diff put)が必要です.以下は、この状況で役に立つ他の通常モードコマンドの小さなリストです。

]c               - advance to the next block with differences
[c               - reverse search for the previous block with differences
do (diff obtain) - bring changes from the other file to the current file
dp (diff put)    - send changes from the current file to the other file
zo               - unfold/unhide text
zc               - refold/rehide text
zr               - unfold both files completely
zm               - fold both files completely

メモ:
通常モードではブロックの上または下の行にありますが、ビジュアルモードではどちらもdo機能しません。dpビジュアルモードでテキスト行を選択するときは、通常のコマンドを使用する必要があります。

  • :'<,'>diffgetそして
  • :'<,'>diffput

また、見ることができます:h copy-diffs

:diffupdate変更があるかどうかファイルを再スキャンします。

おすすめ記事