I'd like to have case-insensitive ex command completion in Vim.
I can accomplish this with:
set ignorecase
" Maybe with
set smartcase
However, the problem with this is that this (obviously) makes the search with /
case-insensitive, which I don't want.
https://github.com/thinca/vim-ambicmd
This plugin did enable case-insensitive ex command completion (and even more functionality), but it also disabled the completion after that. For example, when I mapped <Tab>
to the "expand" key, :NeoBundleUpdate <Tab>
didn't list all the plugins managed by neobundle.vim but entered the <Tab>
character.
I tried doing something like:
nmap / :set noignorecase<CR>/
nmap : :set ignorecase<CR>:
but this made Vim go crazy...
Is there any way I can achieve my goal of having case-insensitive command completion while retaining case-sensitive search?
The help :h /c says:
7. Ignoring case in a pattern /ignorecase
If the 'ignorecase' option is on, the case of normal letters is ignored.
'smartcase' can be set to ignore case when the pattern contains lowercase
letters only.
/\c /\C
When "\c" appears anywhere in the pattern, the whole pattern is handled like
'ignorecase' is on. The actual value of 'ignorecase' and 'smartcase' is
ignored. "\C" does the opposite: Force matching case for the whole pattern.
{only Vim supports \c and \C}
Note that 'ignorecase', "\c" and "\C" are not used for the character classes.
Examples:
pattern 'ignorecase' 'smartcase' matches
foo off - foo
foo on - foo Foo FOO
Foo on off foo Foo FOO
Foo on on Foo
\cfoo - - foo Foo FOO
foo\C - - foo
That would suggest something like nnoremap / /\c
or \C (if you need to change case-sensitivity) in your proposed way.
I think you are looking for the 'wildignorecase' option.
You can keep ignorecase
and smartcase
for command-line completion and make your search case-sensitive with this mapping:
nnoremap / /\C
See :help \C
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With