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

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)
洪涛

Explanation quoted from vim Chinese documentation (http://vimcdoc.sourceforge.net):

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

The problem I encountered that Vimwiki2HTML shortcut keys cannot be used is that <buffer> is "causing trouble".

After installing the vimwiki plug-in with pathogen, there is a vimwiki.vim file under ~/.vim/bundle/vimwiki/ftplugin. There is a shortcut key definition for converting wiki to HTML as follows:

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

<buffer> limits the scope of this shortcut key, then this shortcut key will only be effective for files with the suffix name vimwiki, and will not work for files in other formats.

I was not familiar with ftplugin before, nor was I familiar with the scope of shortcut keys, so I didn’t call up this shortcut key. Thank you to netizen @xuelang for your enthusiastic help.

Finally, I would like to add that both mapleader and localmapleader are customizable.

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

If you also encounter the problem that some shortcut keys in vimwiki cannot be used, you can still use it

:set filetype=vimwiki

Hope this answer will be helpful to netizens who encounter the same problem. :)

黄舟

You don’t need to set the value of localmapleader in vimrc to use the shortcut keys of vimwiki-local-mappings.

For example:
Command: The default shortcut key bound to Vimwiki2HTML in vimwiki is <leader>wh. That is to say, after opening the vimviki file, quickly press the wh keys in normal mode to generate the corresponding html file. Of course, you can also Redefine the shortcut keys yourself, as follows:

nmap <Leader>wc :Vimwiki2HTML

Just add the above key matching in .vimrc.
-------------------------------------------------- ------------
<leader> is generally a key. You can modify the key value represented by <leader>. You can check the help:

:help mapleader
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template