Vim和GVim:领导关键不起作用

Eri*_* Hu 18 vim

我安装了一些插件,包括NERDCommenter和NERDTree.但是,我不能让领导者的钥匙适合他们.这是我输入时的默认配置:map

v  \c<Space>     <Plug>NERDCommenterToggle
n  \c<Space>     <Plug>NERDCommenterToggle
v  \cc           <Plug>NERDCommenterComment
n  \cc           <Plug>NERDCommenterComment
Run Code Online (Sandbox Code Playgroud)

\c<space>就像打击一样c<space>.我已尝试.vimrc在我的主目录中使用以下内容重新映射领导者密钥:

let mapleader = ","
Run Code Online (Sandbox Code Playgroud)

这在我重新启动vim并输入时反映出来 :map

v  ,c<Space>     <Plug>NERDCommenterToggle
n  ,c<Space>     <Plug>NERDCommenterToggle
v  ,cc           <Plug>NERDCommenterComment
n  ,cc           <Plug>NERDCommenterComment
Run Code Online (Sandbox Code Playgroud)

但是,,c<space>只是表现得像我正在打c<space>.发生了什么,我该如何解决这个问题?

编辑:在VIM中测试它也具有相同的行为.

sja*_*jas 16

在加载任何插件之前定义mapleadermaplocalleader键.

就在你的.vimrc之上!


seh*_*ehe 13

我期待,这些映射看起来很有趣

v  <Leader>c<Space>     <Plug>NERDCommenterToggle
n  <Leader>c<Space>     <Plug>NERDCommenterToggle
v  <Leader>cc           <Plug>NERDCommenterComment
n  <Leader>cc           <Plug>NERDCommenterComment
Run Code Online (Sandbox Code Playgroud)

让他们工作.我怀疑你在插件加载设置了mapleader

  • @EricHu:在vimrc,IIRC期间加载插件.尝试将`mapleader`设置移到顶部?另见[**Note**over vimdoc](http://vimdoc.sourceforge.net/htmldoc/map.html#mapleader) (3认同)
  • 当调用`map` /`noremap`时,`<Leader>`和`<LocalLeader>`被展开.如果在设置映射后OP更改了mapleader,则更改将不会反映在它们中. (2认同)

Ros*_*one 12

您可能已将超时设置为零.在那种情况下,vim将不会等待在mapleader之后的密钥.

:set timeout timeoutlen=0 ttimeoutlen=0
Run Code Online (Sandbox Code Playgroud)