gvim - How to understand mapleader and localmapleader in vim?
PHPz
PHPz 2017-05-16 16:42:29
0
2
940

I am a newbie and recently learned to use the vimwkiki plug-in, but some shortcut keys in it cannot be used.
3. Mappings |vimwiki-mappings|
3.1. Global mappings |vimwiki-global-mappings|
3.2. Local mappings |vimwiki-local-mappings|
-------------------------------------------------- -----------------------

  1. vimwiki_<Leader>wh*

<Leader>wh Convert current wiki page to HTML.
Maps to |:Vimwiki2HTML|
To remap: >
:nmap <Leader>wc <Plug>Vimwiki2HTML
-------------------------------------------------- -----------------------
According to the vimwiki help document, the problem lies in the local mappings described in Section 3.2.

Baidu searched for two key words, both of which were repeated content; Google searched for them, but I couldn’t understand them. T.T

Do I need to set the value of localmapleader in vimrc to use the shortcut keys of vimwiki-local-mappings?

The vimwiki version I use is Version: 2.0.1 'stu'

PHPz
PHPz

学习是最好的投资!

reply all(2)
洪涛

引用vim中文文档(http://vimcdoc.sourceforge.net)的解释:

在一个全局插件里应该使用 <Leader> 而在一个文件类型插件里应该用 <LocalLeader>。
"mapleader" 和 "maplocalleader" 可以是相同的。尽管如此,如果你把它们设为不同,
全局插件和文件类型插件的映射冲突的机会是不是会小一点呢?例如,你可以保持把
"mapleader" 设置为缺省的反斜杠,而设置 "maplocalleader" 为下划线。

我遇到的Vimwiki2HTML快捷键无法使用的问题是<buffer>在"作怪".

用pathogen安装完vimwiki插件后,在~/.vim/bundle/vimwiki/ftplugin下有一个vimwiki.vim文件,里面有一个转换wiki到HTML的快捷键定义如下:

if !hasmapto('<Plug>Vimwiki2HTML')
  nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
endif
nnoremap <script><buffer>
      \ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>

<buffer>限定了这个快捷键的作用范围,那么这个快捷键就只对后缀名称是vimwiki的文件有效了,对其他格式的文件不起作用.

我之前对ftplugin不熟悉,对快捷键的作用域也不熟悉,所以没调出这个快捷键来.在这里也谢谢网友@xuelang的热心帮助.

最后再补充一点,mapleader和localmapleader都是可自定义的.

let mapleader = "\\"
let localmapleader = ","

如果你也遇到vimwiki某些快捷键无法使用的问题的时候,还可以使用

:set filetype=vimwiki

希望这个回答对遇到同样问题的网友有所帮助. :)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!