Many plugins make their public mapping interface accessible through <Plug> maps. Users can then use these maps as hooks for their own mappings, e.g. :nmap <Leader>fu <Plug>fooPluginUnlinkRootDir.
Recently I have come across some plugins which put their map names in brackets, e.g.
<Plug>(textobj-indent-a)in the textobj-indent plugin,<Plug>(LineJugglerBlankUp)in the LineJuggler plugin.
This syntax is not documented anywhere in the help files nor do any of the bundled Vim runtime files use it. Nevertheless, these plugins do their job just fine.
What is the motivation for the brackets? Is there any advantage in using them? Should plugin authors be encouraged to follow this practice (as a best practice)?
Thanks ZyX; your answer already covers the fundamentals, so let me just add why I’ve adopted the
<Plug>(PluginNameAndMore)notation. (I think I saw it first in Kana Natsuno’s plugins.)Two reasons:
When wrapping a mapping with other stuff, it’s easier to visually parse the individual mapping targets, like here:
imap <C-x><C-c> <Plug>(CompleteStart)<Plug>(CamelCaseComplete)<SID>(CamelCaseCompleteModifyUndo)<Plug>(CamelCasePostComplete)<Plug>(CompleteoptLongestSelect)When defining multiple mappings for a plugin, one must be careful that the LHS of one is not contained in another mapping. Otherwise, there will be a delay when the mapping is triggered, as Vim needs to wait for additional keystrokes before the ambiguity can be resolved. The closing parenthesis prevents any such ambiguity.