Vim Tips Wiki
Advertisement

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created February 10, 2009 · complexity basic · author Slackdna · version 7.0

hi, ever wondering how to prompt a user for some input from python script within Vim, but first make sure you have imported the vim module

def python_input(message = 'input'):
    vim.command("call inputsave()")
    vim.command("let user_input = input('" + message + " : ')")
    vim.command("call inputrestore()")
    return vim.eval('user_input')

now everytime you wanna prompt user, in your python script do something like

input = python_input('input something')

it will prompt the user to input something with 'input something' as the caption of the prompt, in the command-line

References

Comments

  • Meaningless "make sure..." is not helpful; just give a complete example.
Advertisement