Function: evil-local-mode

evil-local-mode is an interactive and byte-compiled function defined in evil-core.el.

Signature

(evil-local-mode &optional ARG)

Documentation

Minor mode for setting up Evil in a single buffer.

This is a minor mode. If called interactively, toggle the Evil-Local mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate the variable evil-local-mode(var)/evil-local-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(define-minor-mode evil-local-mode
  "Minor mode for setting up Evil in a single buffer."
  :init-value nil
  (if evil-local-mode
      (progn
        (cl-pushnew 'evil-mode-map-alist emulation-mode-map-alists)
        (evil-initialize-local-keymaps)
        (when (minibufferp)
          (setq-local evil-default-state 'insert)
          (setq-local evil-echo-state nil))
        (setq evil-input-method current-input-method)
        (evil-initialize-state)
        (add-hook 'input-method-activate-hook #'evil-activate-input-method t t)
        (add-hook 'input-method-deactivate-hook #'evil-deactivate-input-method t t)
        (add-hook 'activate-mark-hook 'evil-visual-activate-hook nil t)
        ;; FIXME: Add these hooks buffer-locally and remove when disabling
        (add-hook 'pre-command-hook 'evil-repeat-pre-hook)
        (add-hook 'post-command-hook 'evil-repeat-post-hook))
    (evil-refresh-mode-line)
    (remove-hook 'activate-mark-hook 'evil-visual-activate-hook t)
    (remove-hook 'input-method-activate-hook #'evil-activate-input-method t)
    (remove-hook 'input-method-deactivate-hook #'evil-deactivate-input-method t)
    (activate-input-method evil-input-method)
    (evil-change-state nil)))