如何在vimscript中使用sleep仅用于命令行栏?
我正在尝试为 vim 编写一个插件vimscript,我想显示一些特定时间的日志。喜欢:
echo 'some log'
sleep 2
redraw!
当我使用sleepand 时redraw,当前所有窗口都冻结了一段时间,但我只想为了日志而睡眠,而不是所有 vim 窗口!
我怎样才能做到这一点?
回答
sleep will always block. With VIM version 8 you can use timer instead. Here is a stripped down example should not block VIM:
echo 'some log'
let timer = timer_start(2000, 'LogTrigger', {})
func! LogTrigger(timer)
silent! redraw!
endfunc