Am 29.11.2016 um 20:18 schrieb Brett Stahlman:
The 'write-plugin' section of the help recommends the following
3-level map approach:
map ,c <Plug>TypecorrAdd
noremap <unique> <script> <Plug>TypecorrAdd <SID>Add
noremap <SID>Add :call <SID>Add(expand("<cword>"), 1)<CR>
I understand how it works, but it wasn't immediately clear to me what
was being gained by the middle level of indirection: specifically the
map to <SID>Add. What is the advantage of this strategy over the
following 2-level approach?
map ,c <Plug>TypecorrAdd
noremap <unique> <script> <Plug>TypecorrAdd
\ :call <SID>Add(expand("<cword>"), 1)<CR>
Your "2-level approach" contains a mistake: `<script>' should be
removed.
The help says...
"If another script would also map <SID>Add, it would get another
script ID and thus define another mapping."
While this is true, isn't this sort of script-uniqueness already
guaranteed by the use of <SID> in the rhs of the 3rd mapping? I.e.,
:call <SID>Add(...)<CR>
It is.
`<script>' controls "remapping", not "script-uniqueness".
There is ":map" (remapping on) and ":noremap" (remapping off) and then
there is ":noremap <script>" (remapping on for <SID> maps, remapping off
otherwise). ":map <script>" can be used also, it's the same.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.