Skip to content

Instantly share code, notes, and snippets.

@U-MA
Created August 20, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save U-MA/66cc50b1cc3151d109ff to your computer and use it in GitHub Desktop.
Save U-MA/66cc50b1cc3151d109ff to your computer and use it in GitHub Desktop.
function! s:foo(second) abort
let l:start = reltime()
while str2float(reltimestr(reltime(l:start))) < float(a:second)
execute 'normal! r '
endwhile
endfunction
tabnew Sample
call setline(1, 'Please any keys for 2 seconds.')
redraw
call s:foo(2)
call setline(2, 'Return')
let s:key = getchar(0)
while s:key
call setline(line('$')+1, s:key)
let s:key = getchar(0)
endwhile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment