1

I'm working with Vim 8 on the system Ubuntu and I'm thinking if Vim has some mechanism, which is just like the screensaver in Windows.

In a word, I'm trying to do a kind of configuration for my Vim, which is:

if user keeps afk (no typing any key from keyboard) for a while, some job managed by the timer mechanism of Vim 8 will be executed.

I've known how timer_start and timer_stop worked, but I don't know whether Vim could detect afk or not.

1

To detect afk you can use CursorHold and CursorHoldI events.

If you want to run it once:

augroup afk | au!
    autocmd CursorHold,CursorHoldI * ++once echo "Run my timer here"
augroup END

Or everytime user is AFK :

augroup afk | au!
    autocmd CursorHold,CursorHoldI * echo "Run my timer here"
augroup END

Both events are fired after updatetime period of inactivity (default 4 seconds).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.