Saturday, September 10, 2011

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

Hi Jacky,

On 09/11/2011 01:13 AM, Jacky Liu wrote:
> On Sep 11, 2:04 am, Gelonida N <gelon...@gmail.com> wrote:
>>
>> Now I wondered whether there is a way, that python could capture a
>> single key press 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.
>


For my current problem AK's answer is what I was looking for.
I wanted to start a python script and 'guide' it with a few key presses
during it's progress (without having to type return after every key).

so the solution for this kind of issues is:

> import vim
> c = vim.eval("getchar()")
>


I can however imagine situations where your solution might come in quite
handy.

Thanks a lot.


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