6

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?

4

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.

  • This doesn't seem to work under Windows. – SabreWolfy May 16 at 11:35
1

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.

0

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")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.