If you define a function with the abort argument, your function will abort as soon as an error is detected. Is there any case where this is not what you'd want?

Even if your function needs to perform some final cleanup, I'd expect using finally in combination with abort would be the best practice, e.g.

function! Foo() abort
  call s:make_mess()
    call s:might_fail()
    call s:cleanup()

Is there any case where you'd actually want non-abort behavior?

  • Expected failure ?
    – D. Ben Knoble
    Commented Apr 12, 2018 at 14:28

1 Answer 1


Discl.: It's just guessing on my part.

abort didn't exist when function was introduced. I guess that in order to not break existing code it was decided to not change the current behaviour and to provide another behaviour only when functions are explicitly annotated.

Now, where should we not use it? I see no good reason. Even if a non annotated function continues after an error, we do observe many annoying error messages about unbalanced control statements (if, while...).

When I execute code that can fail, I'd rather be explicit with silent!, try...catch or any other specific approach. I do have many non-abort-annotated functions, it's just a sign they are very old and that I haven't upgraded them yet.

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.