0

From a sourced file I am running my vim script. The aim of the script is to run :global. I am searching for

\\%(pattern1.*/)\@<!pattern2

The patterns are variables, so I use execute; for the work to be done, I use a second nested level of execute.

It turns out that within the execute I must use |, not newlines, to separate commands.

execute ' g#' . WE_pattern1 .  ' ' . WE_patter2 . '#execute " try |  ...work | to | be | done... | catch ... | endtry | " '
  1. How can I get the depth of execute-nesting?

  2. How can I :finish the script under some condition? :finish always gives the error message E168: only in sourced ....

  3. I catch CTRL-C interrupts, but after some processing how can I write that CTRL-C will be executed?

1 Answer 1

1
  1. There's simply no need for the second execute (and so neither for nested double-quotes) here.

  2. You can re-throw exception at any point (:h :throw). Of course, it'll become "user-defined", not "Vim:Interrupt". But that should not matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.