On 27-Jan-2012 13:54:45 +0100, Marc Weber wrote:
>> If you happen upon a plugin that simply does something like this:
>> nnoremap <C-x><C-p> :call <SID>MyFunc()<CR>
> one line
>> Kindly ask the plugin author to change it into this:
>> nnoremap <silent> <Plug>(PluginNameMappingName) :call <SID>MyFunc()<CR>
>> if ! hasmapto('<Plug>(PluginNameMappingName)', 'n')
>> nmap <C-x><C-p> <Plug>(PluginNameMappingName)
>> endif
> 4 lines
Yes, there is a certain amount of boilerplate code that plugin authors have to
write (g:loaded_name guard, s:save_cpo, to name the common ones). But this has
never bothered me much, and isn't excessive when compared to other languages.
> My vision is:
> - less docs
> - clean interface which can be read and understand by users
> - follow the principle "Don't repeat yourself".
> Your solution works - but is hard to read.
This is the official recommendation, followed by almost all plugins on vim.org.
Though - like much in Vim(script) - it has an initial learning curve, I haven't
heard many complaints about it.
> Do you call this being an improvement? With my suggestion the user could
> remap it without any additional effort himself. This would keep the
> interfaces of plugins much cleaner. Yes - you can define your own
> Noremap commands - but isn't creating mappings and providing interfaces
> and allowing customizations the most trivial feature Vim should provide?
As an example, I have the following remappings in my .vimrc:
nmap <Leader>#/ <Plug>MarkRegex
nmap <F5> <Plug>ShowScratchBuffer
map ,W <Plug>(smartword-w)
nmap <Leader>tC <Plug>Colorizer
To me, that's as concise and simple as it can get.
But go ahead, implement an alternative, and present the patch here for
discussion. (And be prepared to have a compelling story for backward
compatibility, interoperability and migration of existing plugins, as Bram
thankfully takes these things very serious.)
However, your apparent lack of knowledge about the customary <Plug> idiom
suggests to me that you could rather try out that accepted way first, and maybe
learn to like it eventually. Stay calm, it takes some time until enlightenment
:-)
-- regards, ingo
--
You received this message from the "vim_dev" 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