Emacs: Dired Customization

By Xah Lee. Date: . Last updated: .

Tips for setting up emacs's dired. [see Emacs: File Manager, dired]

Jump to File in Dired

Put this in your emacs init file:

(require 'dired-x)

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

Delete Directory, Copy Directory

Put this in your emacs init file:

;; allow dired to delete or copy dir
(setq dired-recursive-copies (quote always)) ; “always” means no asking
(setq dired-recursive-deletes (quote top)) ; “top” means ask once

Then in dired, Alt+x dired-do-deleteD】 to delete directory.

Target Split Window

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)

Eval the above or restart emacs. [see Evaluate Emacs Lisp Code]

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
Alt+x dired-hide-details-mode. Top is normal dired, bottom is dired with hide details on.

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

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

Hide Some Files

Alt+x dired-do-kill-linesk】 to hide marked files.

Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


Emacs Init

Init Basics

packages

text editing

file

appearance

misc