I have shortcut map in gVim like nmap <a-k> SomeKeySequence:SomeCommand, it seems the last command will not be run if the previous key sequence aborted (like no valid operating target then bell rings), is there a way to let the last command to run even if failure happens in previous operations?

  • Would you please add a specific example of a command you're trying to run and where it's failing to the question? Thanks!
    – cxw
    Commented Sep 3, 2015 at 9:34

1 Answer 1


It depends a little on what exactly you want to do. You can always call a function and handle errors in the function gracefully (e.g. try/catch clauses).

Alternatively, you can wrap your normal mode command into a :exe ":norm" clause, which will not make the mapping abort on erros, e.g. you could do something like this:

nnoremap <f5> :exe ":norm! h"<cr>:echo "done"<cr>

(That is a silly example, but shows, that the echo will also shown, if the cursor is at the start of a line and a left movement is not possible).

  • This works for me. I am wondering why it works.
    – Thomson
    Commented Sep 3, 2015 at 22:01

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.