Skip to content

Commit e00b821

Browse files
authored
Merge pull request #1439 from vim-jp/hh-update-diff
Update diff.{txt,jax}
2 parents 38149dc + 921f572 commit e00b821

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

doc/diff.jax

+45-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*diff.txt* For Vim バージョン 9.1. Last change: 2023 Apr 04
1+
*diff.txt* For Vim バージョン 9.1. Last change: 2024 Feb 01
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -475,4 +475,48 @@ http://gnuwin32.sourceforge.net/packages/diffutils.htm.
475475
その結果スクリプトローカルな要素を使用できる。
476476

477477

478+
☆diff 関数の例 *diff-func-examples*
479+
480+
|diff()| 関数を使用して 2 つの文字列のリスト間の差分インデックスを計算する例を
481+
以下に示す。
482+
>
483+
" いくつかの行が変更された
484+
:echo diff(['abc', 'def', 'ghi'], ['abx', 'rrr', 'xhi'], {'output': 'indices'})
485+
[{'from_idx': 0, 'from_count': 3, 'to_idx': 0, 'to_count': 3}]
486+
487+
" 冒頭に数行を追加した
488+
:echo diff(['ghi'], ['abc', 'def', 'ghi'], {'output': 'indices'})
489+
[{'from_idx': 0, 'from_count': 0, 'to_idx': 0, 'to_count': 2}]
490+
491+
" 冒頭から数行を削除した
492+
:echo diff(['abc', 'def', 'ghi'], ['ghi'], {'output': 'indices'})
493+
[{'from_idx': 0, 'from_count': 2, 'to_idx': 0, 'to_count': 0}]
494+
495+
" 途中に数行を追加した
496+
:echo diff(['abc', 'jkl'], ['abc', 'def', 'ghi', 'jkl'], {'output': 'indices'})
497+
[{'from_idx': 1, 'from_count': 0, 'to_idx': 1, 'to_count': 2}]
498+
499+
" 途中の数行を削除した
500+
:echo diff(['abc', 'def', 'ghi', 'jkl'], ['abc', 'jkl'], {'output': 'indices'})
501+
[{'from_idx': 1, 'from_count': 2, 'to_idx': 1, 'to_count': 0}]
502+
503+
" 末尾に数行を追加した
504+
:echo diff(['abc'], ['abc', 'def', 'ghi'], {'output': 'indices'})
505+
[{'from_idx': 1, 'from_count': 0, 'to_idx': 1, 'to_count': 2}]
506+
507+
" 末尾から数行を削除した
508+
:echo diff(['abc', 'def', 'ghi'], ['abc'], {'output': 'indices'})
509+
[{'from_idx': 1, 'from_count': 2, 'to_idx': 1, 'to_count': 0}]
510+
511+
" ばらばらな変更
512+
:echo diff(['ab', 'def', 'ghi', 'jkl'], ['abc', 'def', 'ghi', 'jk'], {'output': 'indices', 'context': 0})
513+
[{'from_idx': 0, 'from_count': 1, 'to_idx': 0, 'to_count': 1},
514+
{'from_idx': 3, 'from_count': 1, 'to_idx': 3, 'to_count': 1}]
515+
516+
" コンテキスト長 1 のばらばらな変更
517+
:echo diff(['ab', 'def', 'ghi', 'jkl'], ['abc', 'def', 'ghi', 'jk'], {'output': 'indices', 'context': 1})
518+
[{'from_idx': 0, 'from_count': 4, 'to_idx': 0, 'to_count': 4}]
519+
520+
<
521+
478522
vim:tw=78:ts=8:noet:ft=help:norl:

en/diff.txt

+45-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*diff.txt* For Vim version 9.1. Last change: 2023 Apr 04
1+
*diff.txt* For Vim version 9.1. Last change: 2024 Feb 01
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -476,4 +476,48 @@ Otherwise, the expression is evaluated in the context of the script where the
476476
option was set, thus script-local items are available.
477477

478478

479+
DIFF FUNCTION EXAMPLES *diff-func-examples*
480+
481+
Some examples for using the |diff()| function to compute the diff indices
482+
between two Lists of strings are below.
483+
>
484+
" some lines are changed
485+
:echo diff(['abc', 'def', 'ghi'], ['abx', 'rrr', 'xhi'], {'output': 'indices'})
486+
[{'from_idx': 0, 'from_count': 3, 'to_idx': 0, 'to_count': 3}]
487+
488+
" few lines added at the beginning
489+
:echo diff(['ghi'], ['abc', 'def', 'ghi'], {'output': 'indices'})
490+
[{'from_idx': 0, 'from_count': 0, 'to_idx': 0, 'to_count': 2}]
491+
492+
" few lines removed from the beginning
493+
:echo diff(['abc', 'def', 'ghi'], ['ghi'], {'output': 'indices'})
494+
[{'from_idx': 0, 'from_count': 2, 'to_idx': 0, 'to_count': 0}]
495+
496+
" few lines added in the middle
497+
:echo diff(['abc', 'jkl'], ['abc', 'def', 'ghi', 'jkl'], {'output': 'indices'})
498+
[{'from_idx': 1, 'from_count': 0, 'to_idx': 1, 'to_count': 2}]
499+
500+
" few lines removed in the middle
501+
:echo diff(['abc', 'def', 'ghi', 'jkl'], ['abc', 'jkl'], {'output': 'indices'})
502+
[{'from_idx': 1, 'from_count': 2, 'to_idx': 1, 'to_count': 0}]
503+
504+
" few lines added at the end
505+
:echo diff(['abc'], ['abc', 'def', 'ghi'], {'output': 'indices'})
506+
[{'from_idx': 1, 'from_count': 0, 'to_idx': 1, 'to_count': 2}]
507+
508+
" few lines removed from the end
509+
:echo diff(['abc', 'def', 'ghi'], ['abc'], {'output': 'indices'})
510+
[{'from_idx': 1, 'from_count': 2, 'to_idx': 1, 'to_count': 0}]
511+
512+
" disjointed changes
513+
:echo diff(['ab', 'def', 'ghi', 'jkl'], ['abc', 'def', 'ghi', 'jk'], {'output': 'indices', 'context': 0})
514+
[{'from_idx': 0, 'from_count': 1, 'to_idx': 0, 'to_count': 1},
515+
{'from_idx': 3, 'from_count': 1, 'to_idx': 3, 'to_count': 1}]
516+
517+
" disjointed changes with context length 1
518+
:echo diff(['ab', 'def', 'ghi', 'jkl'], ['abc', 'def', 'ghi', 'jk'], {'output': 'indices', 'context': 1})
519+
[{'from_idx': 0, 'from_count': 4, 'to_idx': 0, 'to_count': 4}]
520+
521+
<
522+
479523
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)