How can I delete all user-defined commands where names share a common prefix (e.g. XYZSomeCmd, XYZAnotherCmd, ...)?

Found myself with a lot of dead commands while writing a plugin and changing prefix for commands. Wonder how to clean up without restarting Vim?

1 Answer 1



for cmd in getcompletion("XYZ", "command") | execute "delcommand " . cmd | endfor

Version dependency:

for              " +v7.0031
getcompletion()  " +v7.4.2011
execute()        " +v7.0001
delcommand       " +v7.0001

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.