Emacs: Dired Customization
This page is tips for setting up emacs's dired. See also: emacs dired basics.
How to hide the file's unix owner and permission info?
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)
How to sort files in dired?
How to delete or copy a directory?
Put this in your emacs init:
;; 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-delete 【D】 to delete directory.
How to copy from one dired dir to the next dired dir shown in a split window?
Put this in your emacs init:
(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-rename 【R】 and others.
How to make dired use the same buffer for viewing directory?
In dired, Alt+x dired-find-alternate-file 【a】 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
How to hide some files?
Alt+x dired-do-kill-lines 【k】 to hide marked files.
File Related Tips
In a file, how to go to its directory and place cursor on the file name?
Put this in your init file:
(require 'dired-x)
In any file buffer, Alt+x dired-jump 【Ctrl+x Ctrl+j】 to jump to the directory of current buffer.
How to open a (image, pdf, doc) file in external apps?
How to rename multiple files?
Dired topics
If you have a question, put $5 at patreon and message me.