Automatic leave Insert mode

My vim leave the Insert Mode automatic after few seconds after last input.
The vimrc contains:
autocmd CursorHoldI * stopinsert
Can I get such behavior with kakoune?

Michael

As explained in :doc hooks, Kakoune has an InsertIdle hook that allows you to call a custom command after

a certain duration has passed since the last keypress in insert mode

The value of this duration is determined by the option, idle_timeout in milliseconds (see :doc options). Thus, adding the following lines to your kakrc should do the job:

set-option global idle_timeout 2000
hook -group automatic-leave global InsertIdle .* %{execute-keys -with-hooks <esc>}

Here I assume a timeout value of 2 seconds. The group name for the new hook, automatic-leave, is arbitrary, but is here to allow you to remove the hook easily if you want so. .* is a regex (required by the hook command) that will match any keypress before the timeout. The execute-keys command is executed with hooks just in case you have further hooks that you want to call when entering normal mode. If you have none, the -with-hooks switch is not needed.

4 Likes

Thank you ftonneau,
that is exactly what Im looking for.