Emacs: Dired Customization

By Xah Lee. Date: . Last updated: .

Tips for setting up emacs's dired.

Jump to File in Dired

In any open file, Alt+x dired-jumpCtrl+x Ctrl+j】 to jump to the directory of current buffer.

Before emacs 28, you need to load a lib.

Put this in your Emacs Init File:

(if (version< emacs-version "28.1")
    nil
  (progn
    ;; for dired-jump
    (require 'dired-x)))

Delete Directory, Copy Directory

You can copy or deleted a dir, including all subdirectories.

Put this in your Emacs Init File:

;; allow dired to delete or copy dir
;; 'top means ask once.
;; 'always means no asking

(setq dired-recursive-copies 'top)

(setq dired-recursive-deletes top)

Auto Target Dir in the Other Split Pane

Copy from one dired dir to the next dired dir shown in a split window

Put this in your Emacs Init File:

(setq dired-dwim-target t)

Now, go to dired, then Alt+x split-window-below, then go to another dired dir. Now, when you press C to copy, the other dir in the split pane will be default destination. Same for dired-do-renameR】 and others.

Hide File Owner Permission Info

emacs dired-hide-details-mode 2022-04-22
Alt+x dired-hide-details-mode.

In dired, Alt+x dired-hide-details-mode(】.

If you want it always on, add a hook. Like this:

(defun xah-dired-mode-setup ()
  "to be run as hook for `dired-mode'."
  (dired-hide-details-mode 1))

(add-hook 'dired-mode-hook 'xah-dired-mode-setup)

make dired use the same buffer for viewing directory

In dired, Alt+x dired-find-alternate-filea】 to open the file/directory without creating a new buffer.

If you want Enter and ^ (parent dir) to use the same buffer, put the following in your emacs init file:

(require 'dired )

(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) ; was dired-advertised-find-file

(define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file "..")))  ; was dired-up-directory

Emacs Dired, File Management

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Init

Init Basics

Keys

Font

Text Editing

Completion

File

Restore Things

Backup/AutoSave

Line

Appearance

Misc

Advanced Init Tips

packages