简体   繁体   English

为什么nnoremap不能与CtrlP一起使用,nmap确实有效? - VIM

[英]Why nnoremap doesn't work with CtrlP and nmap does work? - VIM

I have this in my .vimrc 我的.vimrc中有这个

nnoremap <leader>p :CtrlP<CR><C-\>w

I change all nmap to nnoremap in my .vimrc and everything works fine except this one: 我在.vimrc 中将所有nmap更改为nnoremap ,除了这一个之外,一切正常:

nnoremap <leader>p :CtrlP<CR><C-\>w

With nmap <leader>p :CtrlP<CR><C-\\>w it does automatically insert word into CtrlP and with nnoremap it doesn't, I get blank field, like I just pressed Ctrl-P . 使用nmap <leader>p :CtrlP<CR><C-\\>w它会自动将单词插入CtrlP ,而nnoremap则不会,我得到空白字段,就像我按下Ctrl-P一样

Why it doesn't work with nnoremap ? 为什么它不适用于nnoremap

When you create a mapping with nnoremap , it does not consider your prior mappings when resolving what to do. 使用nnoremap创建映射时,在解析要执行的操作时,它不会考虑先前的映射。 In other words, if you had previously mapped any of these: 换句话说,如果您之前已映射过以下任何一个:

<CR>
<C-\>
w

Then those maps would be ignored in your <leader>p mapping, and instead the default action of those keystrokes would be used. 然后,在<leader>p映射中将忽略这些映射,而是使用这些键击的默认操作。

As far as I know, <C-\\> has no default action, so I would suspect you have mapped it (or you are relying on a mapping that another plugin has added), but that mapping is not being taken into account here. 据我所知, <C-\\>没有默认操作,所以我怀疑你已经映射了它(或者你依赖于另一个插件添加的映射),但是这里没有考虑这种映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM