To make functions local, you prefix it with 's:'. But then it can't be called with mappings. Given this function:

function! ScriptFunction()

What convention or keywords do I add to precent name conflicts while still allowing the user to add a mapping?

2 Answers 2


In mappings, script-local functions are called with <sid> instead of s:.

But as indirectly suggested in the other answer, you'd better have the mapping in a plugin and the function in an autoload plugin. It's much better for starting times.

BTW, There is an extensive documentation in 2 parts about mappings on vim.wikia.com


One way is to make a command. I did that in my plugin like so:

execute "command! -buffer -nargs=0 PikeDocOpen :call pikedoc#open()"

You can also use a prefix for the function name (i.e. your plugin name):

function! FOO_ScriptFunction()

But I think that in both cases prefix is a way to go.

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.