微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VimScript:在空闲时间之后采取的动作是否有autocmd?

我想编写一些 vimcript,如果 vim会话空闲了一段时间就会被触发.这可能吗?

解决方法

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

作为一个开始.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐