Skip to content

How to Fix Emacs Evil Mode — Vim Keybindings Not Working

DodaTech Updated 2026-06-24 1 min read

In this tutorial, you'll learn about How to Fix Emacs Evil Mode. We cover key concepts, practical examples, and best practices.

The Problem

Evil mode is not working:

M-x evil-mode

Nothing happens, or Vim keys do not work.

Quick Fix

Step 1: Install Evil properly

(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  :config
  (evil-mode 1))

Step 2: Check that Evil is enabled

M-x evil-mode

Toggle it. The mode line should show <N> (Normal), <I> (Insert), or <V> (Visual).

Step 3: Fix keybinding conflicts

(use-package evil-collection
  :ensure t
  :after evil
  :config
  (evil-collection-init))

Step 4: Configure Evil states

(setq evil-default-state 'normal)
(setq evil-emacs-state-modes '(help-mode ibuffer-mode))

Step 5: Create custom keybindings

(define-key evil-normal-state-map (kbd "C-w") 'evil-delete)
(define-key evil-insert-state-map (kbd "C-e") 'end-of-line)

Prevention

  • Use evil-collection for pre-configured keybindings.
  • Test Evil in a fresh Emacs session.
  • Use C-z to toggle between Evil and Emacs states.

Common Mistakes with evil mode

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world EMACS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between evil-mode and viper?

Evil is a more complete Vim emulation supporting ex commands, visual mode, and text objects. Viper is the built-in basic Vi emulation.

How do I switch between Evil states?

Esc or C-[ for Normal. i for Insert. v for Visual. V for Visual Line.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro