Instead of viewing dired buffers with files sorted by name, I want to view it with directories at the top followed by files grouped by extension (and then filename). Is there any package to install to do that? How do I set up my config?
You can use this:
(setq dired-listing-switches
"-lX --group-directories-first")
The X
option makes it sorted by extension. Basically you can just
google whatever ls
option you want, and then set
dired-listing-switches
accordingly.
Library dired-sort-menu.el
lets you do this (and more): just choose Extension
in the Sort By
submenu of menu Subdir
. (Subdir
is Dir
in Dired+.)
See also library dired-sort-menu+.el
.
You can set dired-listing-switches
to "-l --group-directories-first"
, and then toggle sorting by extension (and other keys) with:
(mapc (lambda (elt)
(define-key dired-mode-map (car elt)
`(lambda ()
(interactive)
(dired-sort-other (concat dired-listing-switches ,(cadr elt))))))
'(([(control f3)] "" "by name")
([(control f4)] " -X" "by extension")
([(control f5)] " -t" "by date")
([(control f6)] " -S" "by size")
([(control shift f3)] " -r" "by reverse name")
([(control shift f4)] " -rX" "by reverse extension")
([(control shift f5)] " -rt" "by reverse date")
([(control shift f6)] " -rS" "by reverse size")))