I'm trying to interrupt a for
loop such as in code below,
for num in buffer_number_list
" Select the buffer
exe 'buffer' num
" Run the command that's passed as an argument
exe a:command
" Save if necessary
update
endfor
instead of interrupting only line exe a:command
, when a:command
is a
:s/// command
.
The purpose is to change code on response to How to do search & replace with ack in vim?
I've tried surrounding the line exe a:command
with a try
/catch
block,
but it doesn't worked, probably because the command handled the interrupt
signal without re-throwing it.
Tried remapping CTRL-c
to change some variable (which would be checked inside of the loop), but it didn't worked:
let original_Ctrl_c = maparg('<c-c>', 'n')
exe 'nnoremap <c-c> :call <SID>BreakLoop()<CR>' . original_Ctrl_c
It seems that the mapping didn't trigger when the interrupt signal is caught.
Any ideas?
EDIT:
It seems that this problem only occurs in gVim (thanks @ib.)