It fails because do_map
returns 2 for unknown mapping and this code throws error for this case. Not very helpful, I guess. Annotate says that this code did not change from the very first version of vim found in the mercurial repository (7.0001).
There may be different answers: I can guess of three:
- vi compatibility:
vi
did throw and so should vim do - it is right thing to do: if command did not do what it was requested to do it should report failure
- it provides more options: if unmapping an existing mapping is essential you can catch the error using
:try
..:catch
(or leave as-is indicating the error to user), if it is not there is alwayssilent!
. Argument for EAFP principle adepts and users with tiny vim though: in VimL usingmaparg()
to check for existence is more common, but it requires+eval
(if I am not mistaking:try
does this as well: the whole meaningfulex_eval.c
file contents where this command is defined is guarded with#if defined(FEAT_EVAL) || defined(PROTO)
).
But Stackoverflow is not the right place to ask such questions. For such old code only Bram may know the answer and thus the question should be asked on vim-dev. If I were him I would ask an explanation why you need the answer though.