Saturday, July 23, 2011

Use and meaning of

What is the actual value of using <plug>? I've always seen the same pattern:

map <unique> <Leader>XY <Plug>MyscriptMyfunction
noremap <unique> <script> <Plug>MyscriptMyfunction <SID>Myfunction
noremap <SID>Myfunction :call <SID>Myfunction()<CR>

As far as I understand, <plug> allows users of a (third party) plugin
to define their own mappings to symbols defined in the plugin as
<SID>Something. This is apparently necessary because the actual value
of <SID> is not known in advance and it could change in the course of
time. However, in order to make use of <plug>, the plugin author is
expected to craft a name which is globally unique, for instance by
following the convention '<Plug> scriptname mapname', so that this
name does not clash with other from other plugins. In the example
above, this would correspond to '<plug>MyscriptMyfunction'. But then,
what good is the whole <SID> thing, if the plugin author is still
expected to use unique global identifiers (here MyscriptMyfunction)?
Wouldn't the following line solve the problem given the same
assumptions (instead of the three above)?

map <unique> <Leader>YX :call MyscriptMyfunction()<CR>

I'm evidently missing the main point and I'd be most grateful if
somebody could show me the light :-)

--
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

No comments: