I'm trying to write a simple plugin that let user input something, and while inputing, the plugin echos the input text in real time.
So far the script shows result after Enter pressed:
function! Test() let curline = getline('.') call inputsave() let name = input('Enter name: ') call inputrestore() call setline('.', curline . ' ' . name) endfunction
How to improve it to handle real time input? I searched for
:h input but I don't see any typing callback.
getchar works, but the text input is not displayed, I need to see the text input and modify it, like the
input(message) feature, is it possible?
function! s:getchar() let c = getchar() if c =~ '^\d\+$' let c = nr2char(c) endif return c endfunction " Interactively change the window title function! InteractiveTest() let char = "s" while char =~ '^\w$' echo "input to change title" let char = s:getchar() let &titlestring=char redraw endwhile endfunction