0

In :help using-<Plug> a suggestion is given as to how to name the left hand side of a <Plug> mapping:

To make it very unlikely that other plugins use the same sequence of characters, use this structure: <Plug> scriptname mapname
In our example the scriptname is "Typecorr" and the mapname is "Add". We add a semicolon as the terminator. This results in "TypecorrAdd;".

but I don't understand what the purpose of the ; is.

1 Answer 1

1

If I understand the given example correctly, the purpose of that semicolon is to visually separate the <Plug> mapping from any subsequent command, as in the imaginary:

nmap xx <Plug>FooBarx    " Is it 'rx' at the end?
nmap xx <Plug>FooBar;x   " Oh… OK I guess

But I don't think that's a particularly good pattern, mostly because ; is a legitimate command, which can lead to more confusion. And it is only provided as an example anyway, not as a guideline. The name doesn't have to be in PascalCase and it doesn't have to end with a semicolon either.

AFAIK, the most common real world pattern is actually to wrap the name in parentheses:

<Plug>(FooBar)
<Plug>(foo_bar)
" etc.

which makes boundaries very clear and non-ambiguous, in a "it starts here and it ends there" kind of way:

nmap xx <Plug>(FooBar)x

Note that the parentheses are not some obscure vimscript expression thing, they are literally part of the name so you can be creative:

<Plug><FooBar>
<Plug>[fooBar]
<Plug>{foo_bar}
<Plug>§1337§
" etc.

at the risk of puzzling both your users and your fellow community members trying to help.

You should stick with the parentheses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.