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!– cxwSep 3, 2015 at 9:34
1 Answer
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).