On Sep 11, 2:04 am, Gelonida N <[email protected]> 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.



Simple, just delete all the 'prompt's from your code and you'll get a
new recipe *without any prompt*.

Just joking -- maybe this will do:

    nnoremap <buffer>   \\      :py3 do_something()<CR>

    python3 << EOF

    def do_something():
            pass

    EOF

Now python will get informed  whenever you press '\\' in normal mode.
I suppose you wouldn't like to have it on in all circumstances so the
'<buffer>' specifier would most likely be useful here.

-- 
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

Reply via email to