Search code examples
vimuser-input

Is it possible to display multiple choice dialog in gVIM?


I have a gVIM script that parses current buffer and offers user to select one of multiple choices. It is implemented as console input, but since i'm using graphical version of gVIM, maybe it's possible to use graphical version of multiple choice dialog? I have tried to use python + Tkinter but it's very unstable and is not working on some NIX boxes :(. Any ideas?


Solution

  • After some research i have found a solution. VIM supports so-called "clientserver" mode and external application can send a command to it. So this task (and many others) can be solved with following technique (tested on Windows, OSX and Ubuntu):

    1. VIMscript that handles a command launches standalone GUI script in separate process and returns.
    2. Standalone GUI script (python/ruby/.exe/whatever) displays GUI and waits for user interaction.
    3. After user interaction, standalone GUI script closes it's window, communicates back to VIM via "clientserver" interface (call another script, open file, move cursor etc) and exits.