Prompts

There are two primary ways to prompt the user for input. You can either use confirm to display a multiple choice dialog (such as yes/no/cancel), or input to process a more complex input.

The confirm function prompts the user with a dialog and a multiple answers a user can select from. Let's try a simple example:

let answer = confirm('Is cat your favorite animal?', "&yes\n&no")echo answer

If you execute the script, you'll get the following prompt:

Hitting y or n will select an option. Let's hit y:

The result of this is 1. Now, what if ...

Get Mastering Vim now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.