Thursday, August 15, 2019

Re: nnoremap nmap confusion

Am 14.08.2019 um 21:51 schrieb Kai Weber:
> * 'Andy Wokula' via vim_use <vim_use@googlegroups.com>:
>
>>> The plugin srstevenson/vim-picker defines a list of mappings:
>>
>> I read those https://github.com/srstevenson/vim-picker README for you:
>> it suggests :nmap for your mappings ... no cargo-cult here.
>
> You are right. But why?
> Why does nnoremap not work?

:nmap
= remapping on
=check the right hand side for user-defined left-hand-sides (and expand them recursively)
when it comes to executing the mapping

:nnoremap
= remapping off
= interpret the right hand side as if there were no mappings defined

There is no builtin command starting with <Plug>
(and important for plugin writers: there is no key "<Plug>" on your keyboard).
(If you need a beep, try
:exec "normal! \<Plug>"
)
The only thing starting with <Plug> is a user-defined mapping, usually from a plugin.


Help pointers:
:h :nmap
:h :nnoremap
:h <Plug>
:h map-listing
the latter explains `*' in the map listing.

(:help is essential. Also try <Tab> and Ctrl-D for completion, and wildcards `*' and `?'
search around with `/', try :helpgrep, etc.).


" ok:
:nnoremap <silent> <Plug>(PickerEdit) :PickerEdit<CR>

" wrong:
:nmap <silent> <Plug>(PickerEdit) :PickerEdit<CR>
" eg user swapped `;' and `:' via mapping => right hand side becomes `;PickerEdit<CR>'

" ok:
nmap <unique> <Leader>E <Plug>(PickerEdit)

" wrong:
nnoremap <unique> <Leader>E <Plug>(PickerEdit)
" just beeps, no builtin command starting with <Plug>

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5D55B75B.7030502%40yahoo.de.

No comments: