Vim:不区分大小写的 ex 命令完成

Nig*_*oJr 6 vim case-sensitive case-insensitive

我想在 Vim 中有不区分大小写的 ex 命令完成。

我可以通过以下方式完成此操作:

set ignorecase
" Maybe with
set smartcase
Run Code Online (Sandbox Code Playgroud)

但是,问题在于这(显然)使搜索/不区分大小写,这是我不想要的。

https://github.com/thinca/vim-ambicmd

这个插件确实启用了不区分大小写的 ex 命令完成(甚至更多的功能),但之后它也禁用了完成。比如我映射<Tab>到“expand”键时,:NeoBundleUpdate <Tab>没有列出neobundle.vim管理的所有插件,而是输入了<Tab>字符。

我尝试做类似的事情:

nmap / :set noignorecase<CR>/
nmap : :set ignorecase<CR>:
Run Code Online (Sandbox Code Playgroud)

但这让 Vim 发疯了......

有什么方法可以实现不区分大小写的命令完成同时保留区分大小写的搜索的目标吗?

mik*_*ike 6

帮助 :h /c 说:

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
Run Code Online (Sandbox Code Playgroud)

这会nnoremap / /\c以您建议的方式建议类似或 \C (如果您需要更改区分大小写)。