0

I run a sourced vimscript like this:

exec 'g#' . WE_var_searchmode . ' ' . WE_var_pattertosearch . '#exec " A | B | C | make_CTRL-C | ... | LAST " '

The outer execute '...' is needed to pass variables as patterns. The inner execute " ... " is needed so that the global command repeatedly executes some code.

On some condition, the repetition by :global is to be broken, like breaking a while loop. The help states that for :global only CTRL-C interrupts. Thus typing CTRL-C does work. But how can I write code in the script to interrupt?

I have not found a way; all my trials to produce CTRL-C result in error messages.

2
  • You might not need the inner execute if A | B | C … are not built out of variables/strings. I would try :execute "normal! \<C-c>" or :call feedkeys("\<C-c>").
    – D. Ben Knoble
    Oct 22 '21 at 1:02
  • I've noticed you ask a few questions with similar content. I've edited them in the hopes that they will be more likely to attract answers with readable content, but the best way to get an answer is to be specific. Find a small example that demonstrates your issue. It's also possible we can suggest alternate ways to go about solving your problem which may help eliminate the need for some of the complexity you seem to be dealing with.
    – D. Ben Knoble
    Oct 22 '21 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.