Maxwell Midega
Maxwell Midega

Reputation: 1

Using evil-mode in dired or disable evil-mode in dired

I have been using emacs for note-taking with org mode. I don't like other note-taking apps. I have come to like emacs for other tasks as well. However, I have trouble navigating dired with evil-mode. I have to Ctrl-z every time I want to open a new directory or file and it's tiresome. Is there a way I can navigate dired while in evil-mode. Or, how do I disable evil-mode when I'm in dired without having to Ctrl-z every time?

Here's my evil-mode config

(defun rune/evil-hook ()
  (dolist (mode '(custom-mode
          eshell-mode
          git-rebase-mode
          erc-mode
          circe-server-mode
          circe-chat-mode
          circe-query-mode
          sauron-mode
          term-mode))
    (add-to-list 'evil-emacs-state-modes mode)))

;; Evil mode
(use-package evil
  :init
  (setq evil-want-integration t)
  (setq evil-want-keybinding nil)
  (setq evil-want-C-u-scroll t)
  (setq evil-want-C-i-jump nil)
  :config
  (evil-mode 1)
  (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
  (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)

  ;; Use visual line motions even outside of visual-line-mode buffers
  (evil-global-set-key 'motion "j" 'evil-next-visual-line)
  (evil-global-set-key 'motion "k" 'evil-previous-visual-line)

  (evil-set-initial-state 'messages-buffer-mode 'normal)
  (evil-set-initial-state 'dashboard-mode 'normal))

I have tried searching everywhere but I can't get what I'm looking for. I have to admit, the Emacs manual is a bit too long and I just feel lazy to read the whole thing. I have only read enough to understand the basics.

Upvotes: 0

Views: 1905

Answers (1)

Tianshu Wang
Tianshu Wang

Reputation: 758

You are almost there, to enable emacs state in dired mode, you can just

(evil-set-initial-state 'dired-mode 'emacs)

However, I suggest using evil-collections to better keep using Evil in dired-mode. This package provide a set of keybindings for Evil mode, much more than just dired-mode.

Upvotes: 1

Related Questions