Saturday, September 10, 2011

Re: reading a singly character from a python script for vim

On 09/10/2011 02:04 PM, Gelonida N wrote:
> Hi,
>
>
> Concerning vim scripting I'm an absolute beginner, so forgive my if
> the answer to my question is obvious
>
>
> J just started looking at what would be possible from within a
> vim-python script.
>
>
> If I want to get text input from the user (with a prompt) I found
> following recipe.
>
> def readline(prompt):
> vim.command('call inputsave()')
> vim.command('let user_input = input("%s")' % prompt)
> vim.command('call inputrestore()')
> return vim.eval('user_input')
>
>
>
> Now I wondered whether there is a way, that python could capture a
> single key press without any prompt.
>
>
> Thanks in advance for suggestions.
>
>
>
>
>


I think you can do something like:

from vim import *
c = eval("getchar()")

-ak

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: