-*options.txt* For Vim version 9.1. Last change: 2025 Sep 10
+*options.txt* For Vim version 9.1. Last change: 2025 Sep 11
VIM REFERENCE MANUAL by Bram Moolenaar
*'dip'* *'diffopt'*
'diffopt' 'dip' string (default
- "internal,filler,closeoff,inline:simple")
+ "internal,filler,closeoff,indent-heuristic,inline:char")
global
{not available when compiled without the |+diff|
feature}
-*version9.txt* For Vim version 9.1. Last change: 2025 Sep 10
+*version9.txt* For Vim version 9.1. Last change: 2025 Sep 11
VIM REFERENCE MANUAL by Bram Moolenaar
- the default value for 'showcmd' is always enabled when using non-compatible
mode (previously, it was off on UNIX systems) and consequently removed from
|defaults.vim|
+- Improve the diff experience by updating the 'diffopt' default value to
+ "internal,filler,closeoff,indent-heuristic,inline:char".
Completion: ~
- allow to complete directories from 'cdpath' for |:cd| and similar commands,
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
#define ALL_INLINE (DIFF_INLINE_NONE | DIFF_INLINE_SIMPLE | DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
#define ALL_INLINE_DIFF (DIFF_INLINE_CHAR | DIFF_INLINE_WORD)
-static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
+static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF | DIFF_INLINE_CHAR;
-static long diff_algorithm = 0;
+static long diff_algorithm = XDF_INDENT_HEURISTIC;
#define LBUFLEN 50 // length of line in diff file
|P_NODUP,
#ifdef FEAT_DIFF
(char_u *)&p_dip, PV_NONE, did_set_diffopt, expand_set_diffopt,
- {(char_u *)"internal,filler,closeoff,inline:simple",
+ {(char_u *)"internal,filler,closeoff,indent-heuristic,inline:char",
(char_u *)NULL}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
|~| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
|X+3#0000000&|d|i|f|i|l|e|1| @10|1|,|0|-|1| @9|A|l@1| |X+1&&|d|i|f|i|l|e|2| @10|1|,|0|-|1| @9|A|l@1
-|:+0&&|s|e|t| |d|i|f@1|o|p|t|+|=|i|n|t|e|r|n|a|l| @52
+|:+0&&| @73
| +0#0000e05#a8a8a8255@1|b+8#ffffff16#ff404010|e@1| @31||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31||+1&&| +0#0000e05#a8a8a8255@1>f+8#ffffff16#ff404010|o@1| @31
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31
-| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010|a|z| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010|o@1| +0&#ffd7ff255@31
-| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|a|r| @31
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|z+2&#ff404010| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010|o@1| +0&#ffd7ff255@31
+| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|r+2&#ff404010| +0&#ffd7ff255@31
|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|e@1| @31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31
| +0#0000e05#a8a8a8255@1|f+8#ffffff16#ff404010|o@1| @31||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1>f+8#ffffff16#ff404010|o@1| @31
-| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010|a|z| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010|o@1| +0&#ffd7ff255@31
-| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|a|r| @31
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|z+2&#ff404010| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010|o@1| +0&#ffd7ff255@31
+| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|r+2&#ff404010| +0&#ffd7ff255@31
|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|e@1| @31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @31
-| +0#0000e05#a8a8a8255@1|b+10#ffffff16#ff404010|a|z| +8&&@31||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1>f+10#ffffff16#ff404010|o@1| +8&&@31
-| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#5fd7ff255|a|r| @31
+| +0#0000e05#a8a8a8255@1|b+8#ffffff16#ff404010|a|z+10&&| +8&&@31||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1>f+10#ffffff16#ff404010|o@1| +8&&@31
+| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|r+2&#ff404010| +0&#ffd7ff255@31
|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
|~| @35||+1#0000000&|~+0#4040ff13&| @35
--- /dev/null
+|<+0#4040ff13#ffffff0@2| +0#0000000&|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a||+1&&|<+0#4040ff13&@2| +0#0000000&|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| ||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c|
+| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c||+1&&| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| @14||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| @14
+| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010|o@1| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010|a|r|b+0&#ffd7ff255|a>r| @28
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffd7ff255|a|r| @31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b
+| +0#0000e05#a8a8a8255@1|c+0#0000000#ffffff0| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a||+1&&| +0#0000e05#a8a8a8255@1|c+0#0000000#ffffff0| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| ||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c|
+| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c||+1&&| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b
+| +0#0000e05#a8a8a8255@1|c+0#0000000#ffffff0| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a||+1&&| +0#0000e05#a8a8a8255@1|c+0#0000000#ffffff0| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a
+| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| ||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c|
+| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c||+1&&| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| @14||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0|a|b|c| |a|b|c| |a|b|c| |a|b|c| |a|b|c| @14
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|~| @35||+1#0000000&|~+0#4040ff13&| @35
+|[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|2|,|4| @11|A|l@1| |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @5|2|,|6| @11|A|l@1
+| +0&&@74
endfunc
func Test_diff_hlID()
+ set diffopt=internal,filler
new
call setline(1, [1, 2, 3, 'Yz', 'a dxxg',])
diffthis
call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "")
%bwipe!
+ set diffopt&
endfunc
func Test_diff_filler()
call term_sendkeys(buf, ":set diffopt+=algorithm:histogram\<cr>")
call VerifyScreenDump(buf, 'Test_diff_09', {})
- " Test 10-11: normal/indent-heuristic
+ " Test 10-11: with/without indent-heuristic
call term_sendkeys(buf, ":set diffopt&vim\<cr>")
call WriteDiffFiles(buf, ['', ' def finalize(values)', '', ' values.each do |v|', ' v.finalize', ' end'],
\ ['', ' def finalize(values)', '', ' values.each do |v|', ' v.prepare', ' end', '',
\ ' values.each do |v|', ' v.finalize', ' end'])
call term_sendkeys(buf, ":diffupdate!\<cr>")
- call term_sendkeys(buf, ":set diffopt+=internal\<cr>")
- call VerifyScreenDump(buf, 'Test_diff_10', {})
+ call term_sendkeys(buf, ":set diffopt+=internal\<cr>:\<cr>")
+ call VerifyScreenDump(buf, 'Test_diff_11', {})
" Leave trailing : at commandline!
- call term_sendkeys(buf, ":set diffopt+=indent-heuristic\<cr>:\<cr>")
- call VerifyScreenDump(buf, 'Test_diff_11', {}, 'one')
+ call term_sendkeys(buf, ":set diffopt-=indent-heuristic\<cr>:\<cr>")
+ call VerifyScreenDump(buf, 'Test_diff_10', {}, 'one')
" shouldn't matter, if indent-algorithm comes before or after the algorithm
call term_sendkeys(buf, ":set diffopt&\<cr>")
call term_sendkeys(buf, ":set diffopt+=indent-heuristic,algorithm:patience\<cr>:\<cr>")
call writefile(lines, 'Xprogram2.c', 'D')
let lines =<< trim END
+ set diffopt=internal,filler
edit Xprogram1.c
diffsplit Xprogram2.c
END
CheckScreendump
let content =<< trim END
+ set diffopt=internal,filler
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
vnew
call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
" Test for adding/removing lines inside diff chunks, between diff chunks
" and before diff chunks
func Test_diff_modify_chunks()
+ set diffopt=internal,filler
enew!
let w2_id = win_getid()
call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
call assert_equal(['', '', '', '', '', '', '', '', ''], hl)
%bw!
+ set diffopt&
endfunc
func Test_diff_binary()
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
" enable linematch
- call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
call WriteDiffFiles(buf, ['// abc d?',
\ '// d?',
\ '// d?' ],
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
" setup a diff with 2 files and set linematch:30, with ignore white
- call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
call WriteDiffFiles(buf, ['void testFunction () {',
\ ' for (int i = 0; i < 10; i++) {',
\ ' for (int j = 0; j < 10; j++) {',
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
" a diff that would result in multiple groups before grouping optimization
- call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
call WriteDiffFiles(buf, ['!A',
\ '!B',
\ '!C' ],
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
" a diff that would result in multiple groups before grouping optimization
- call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
call WriteDiffFiles(buf, ['!A',
\ '!B',
\ '!C' ],
let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
- call term_sendkeys(buf, ":set diffopt+=linematch:10\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:10\<CR>")
" a diff block will not be aligned with linematch because it's contents
" exceed 10 lines
call WriteDiffFiles(buf,
call term_sendkeys(buf, "1\<c-w>w:set autoread\<CR>")
call term_sendkeys(buf, "2\<c-w>w:set autoread\<CR>")
call term_sendkeys(buf, "3\<c-w>w:set autoread\<CR>")
- call term_sendkeys(buf, ":set diffopt+=linematch:30\<CR>")
+ call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
call WriteDiffFiles3(buf,
\ ["",
\ " common line",
call delete('.Xfile_linematch2.swp')
call delete('.Xfile_linematch3.swp')
let lines =<< trim END
- set diffopt+=linematch:60
+ set diffopt=internal,filler,linematch:60
call feedkeys("Aq\<esc>")
call feedkeys("GAklm\<esc>")
call feedkeys("o")
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_diff_change_line_default()
+ CheckScreendump
+
+ " Uses the new diffopt default with indent-heuristic and inline:char
+ let lines =<< trim END
+ set diffopt=internal,filler,closeoff,indent-heuristic,inline:char,followwrap smoothscroll
+ call setline(1, repeat(' abc', &columns))
+ call setline(2, 'bar')
+ call setline(3, repeat(' abc', &columns))
+ vnew
+ call setline(1, repeat(' abc', &columns))
+ call setline(2, 'foo')
+ call setline(3, 'bar')
+ call setline(4, repeat(' abc', &columns))
+ windo exe "normal! 2gg5\<C-E>"
+ windo diffthis
+ END
+ call writefile(lines, 'XSmoothDiffChangeLine', 'D')
+ let buf = RunVimInTerminal('-S XSmoothDiffChangeLine', #{rows: 20, columns: 55})
+
+ call VerifyScreenDump(buf, 'Test_smooth_diff_change_line_1', {})
+ call term_sendkeys(buf, "Abar")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_change_line_2', {})
+ call term_sendkeys(buf, "\<Esc>")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_change_line_3a', {})
+ call term_sendkeys(buf, "yyp")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_change_line_4', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_smoothscroll_diff_change_line()
CheckScreendump
+ " Uses the old diffopt default
let lines =<< trim END
- set diffopt+=followwrap smoothscroll
+ set diffopt=internal,filler,closeoff,followwrap,inline:simple smoothscroll
call setline(1, repeat(' abc', &columns))
call setline(2, 'bar')
call setline(3, repeat(' abc', &columns))
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1753,
/**/
1752,
/**/