4

I was wondering if anyone has ever looked at a way to switch back to normal mode automatically after inaction? In Vim, there are several methods to do that, such as:

http://vim.wikia.com/wiki/To_switch_back_to_normal_mode_automatically_after_inaction

4

The following function and idle timer will force evil back into normal state in all buffers after an idle delay of 30 seconds (which you can adjust as you like):

(defun evil-normalize-all-buffers ()
  "Force a drop to normal state."
  (unless (eq evil-state 'normal)
    (dolist (buffer (buffer-list))
      (set-buffer buffer)
      (unless (or (minibufferp)
                  (eq evil-state 'emacs))
        (evil-force-normal-state)))
    (message "Dropped back to normal state in all buffers")))

(defvar evil-normal-timer
  (run-with-idle-timer 30 t #'evil-normalize-all-buffers)
  "Drop back to normal state after idle for 30 seconds.")
  • perfect! this works well – zeltak Jul 12 '16 at 14:12

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.