-*options.txt* For Vim version 9.1. Last change: 2025 May 07
+*options.txt* For Vim version 9.1. Last change: 2025 May 08
VIM REFERENCE MANUAL by Bram Moolenaar
Override the 'ignorecase' option if the search pattern contains upper
case characters. Only used when the search pattern is typed and
'ignorecase' option is on. Used for the commands "/", "?", "n", "N",
- ":g" and ":s". Not used for "*", "#", "gd", tag search, etc. After
- "*" and "#" you can make 'smartcase' used by doing a "/" command,
- recalling the search pattern from history and hitting <Enter>.
+ ":g" and ":s" and when filtering matches for the completion menu
+ |compl-states|.
+ Not used for "*", "#", "gd", tag search, etc. After "*" and "#" you
+ can make 'smartcase' used by doing a "/" command, recalling the search
+ pattern from history and hitting <Enter>.
NOTE: This option is reset when 'compatible' is set.
*'smartindent'* *'si'* *'nosmartindent'* *'nosi'*
delfunc PrintMenuWords
endfunc
+" Test normal mode (^N/^P/^X^N/^X^P) with smartcase when 1) matches are first
+" found and 2) matches are filtered (when a character is typed).
+func Test_smartcase_normal_mode()
+
+ func! PrintMenu()
+ let info = complete_info(["matches"])
+ call map(info.matches, {_, v -> v.word})
+ return info
+ endfunc
+
+ func! TestInner(key)
+ let pr = "\<c-r>=PrintMenu()\<cr>"
+
+ new
+ set completeopt=menuone,noselect ignorecase smartcase
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}{pr}"
+ call assert_equal('F{''matches'': [''Fast'', ''FAST'', ''False'',
+ \ ''FALSE'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}a{pr}"
+ call assert_equal('Fa{''matches'': [''Fast'', ''False'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}a\<bs>{pr}"
+ call assert_equal('F{''matches'': [''Fast'', ''FAST'', ''False'',
+ \ ''FALSE'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}ax{pr}"
+ call assert_equal('Fax{''matches'': []}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}ax\<bs>{pr}"
+ call assert_equal('Fa{''matches'': [''Fast'', ''False'']}', getline(1))
+
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}A{pr}"
+ call assert_equal('FA{''matches'': [''FAST'', ''FALSE'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}A\<bs>{pr}"
+ call assert_equal('F{''matches'': [''Fast'', ''FAST'', ''False'',
+ \ ''FALSE'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}AL{pr}"
+ call assert_equal('FAL{''matches'': [''FALSE'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}ALx{pr}"
+ call assert_equal('FALx{''matches'': []}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOF{a:key}ALx\<bs>{pr}"
+ call assert_equal('FAL{''matches'': [''FALSE'']}', getline(1))
+
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOf{a:key}{pr}"
+ call assert_equal('f{''matches'': [''Fast'', ''FAST'', ''False'', ''FALSE'',
+ \ ''fast'', ''false'']}', getline(1))
+ %d
+ call setline(1, ["Fast", "FAST", "False", "FALSE", "fast", "false"])
+ exe $"normal! ggOf{a:key}a{pr}"
+ call assert_equal('fa{''matches'': [''Fast'', ''FAST'', ''False'', ''FALSE'',
+ \ ''fast'', ''false'']}', getline(1))
+
+ %d
+ exe $"normal! ggOf{a:key}{pr}"
+ call assert_equal('f{''matches'': []}', getline(1))
+ exe $"normal! ggOf{a:key}a\<bs>{pr}"
+ call assert_equal('f{''matches'': []}', getline(1))
+ set ignorecase& smartcase& completeopt&
+ bw!
+ endfunc
+
+ call TestInner("\<c-n>")
+ call TestInner("\<c-p>")
+ call TestInner("\<c-x>\<c-n>")
+ call TestInner("\<c-x>\<c-p>")
+ delfunc PrintMenu
+ delfunc TestInner
+endfunc
+
" Test 'nearest' flag of 'completeopt'
func Test_nearest_cpt_option()