0

If I edit a file outside of a Vim session, then go back to the Vim session, I get this nice message:

W11: Warning: File "~/.vimrc" has changed since editing started
See ":help W11" for more info.
[O]K, (L)oad File:

How does it work?

I know that

  • inputlist({textlist}) prompts the user to type numbers corresponding to the indices of the alternatives
  • input({prompt} [, {text} [, {completion}]]) prompts the user to type "extended" text

Whereas the message prompt I pasted above just requires the user to hit Y or N.

How do I replicate this functionality?

1

See :h confirm().

" prefer console dialogs in GVim too
"set guioptions+=c

let text =<< trim END
    W11: Warning: File "~/.vimrc" has changed since editing started
    See ":help W11" for more info.
END
echo confirm(join(text, "\n"), "&OK\n&Load File", 1, "Warning")

Your Answer

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

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