In an unusual state, I want to ensure that a user sees a warning message upon startup, and presses a key to continue.

I could use sleep <seconds>, but I'm sure that vim can do this. Go vim!

2 Answers 2


You can use the input function, e.g.

call input('Press any key to continue')

See :h input().

  • 1
    To add to your answer, you could also do inputdialog('Press any key to continue') for GUI.
    – DJMcMayhem
    Sep 27, 2016 at 6:27
  • 2
    Close. You've implemented "Press enter to continue". Not exactly what I was looking for.
    – Tom Hale
    Sep 27, 2016 at 7:16
  • True. Sorry, I was a little bit too quick here. I think @IngoKarkat's answer is then more correct, in particular with the getchar() function. I could update my answer, but I think it is more fair to mark Ingo's answer as correct. Sep 27, 2016 at 13:09
  • For a confirmation, I would use :call confirm('My warning here'); this uses a popup window in GVIM.
  • To wait for any character, you can use :call getchar().
  • For a confirmation with Enter, the already mentioned :call input('Press enter to continue')

Many people would consider such mandatory interrupt bad user experience. I don't know about your exact use case, but in general, I would just :autocmd VimEnter * echoerr 'Houston, we have a problem'. If the user somehow didn't see the message, :messages will recall them.

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.