gpt4 book ai didi

VimScript : is there an autocmd for an action taken after idle time?

转载 作者:行者123 更新时间:2023-12-04 07:44:41 24 4
gpt4 key购买 nike

我想写一些vimscript,如果vim session 闲置了一段时间,该脚本会被触发。这可能吗?

最佳答案

:help CursorHold

When the user doesn't press a key for the time
specified with 'updatetime'. Not re-triggered
until the user has pressed a key (i.e. doesn't
fire every 'updatetime' ms if you leave Vim to
make some coffee. :) See |CursorHold-example|
for previewing tags.
This event is only triggered in Normal mode.
It is not triggered when waiting for a command
argument to be typed, or a movement after an
operator.
While recording the CursorHold event is not
triggered. |q|
Note: Interactive commands cannot be used for
this event. There is no hit-enter prompt,
the screen is updated directly (when needed).
Note: In the future there will probably be
another option to set the time.
Hint: to force an update of the status lines
use: >
:let &ro = &ro
{only on Amiga, Unix, Win32, MSDOS and all GUI
versions}
*CursorHoldI*

因此,您可以尝试
let g:idle_counter = 0
function! Idle()
echo "I am idle!!!! (" . g:idle_counter . ")"

let g:idle_counter = g:idle_counter + 1
endfunction

autocmd CursorHold * call Idle()

作为一个开始。

关于VimScript : is there an autocmd for an action taken after idle time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4693983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com