1

I am using Emacs 27.1 (GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-28, modified by Debian) with "default" dired mode. There are no settings or extra packages related to dired mode in my init.el.

By default I see hidden (dotted) files and folders. Can I toggle that with a key shortcut?

3

What is your value of option dired-listing-switches (press M-: and type dired-listing-switches)? Customize it to use a value that does not list hidden files. In other words, this is about the switches you tell Dired to use with ls.

You can also change the switches anytime, for a given Dired buffer, by invoking dired with a prefix arg (e.g. C-u).

For example, removing a from dired-listing-switches will likely do what you want: prevent listing files whose names start with ..

2
  • OK, it is `"-al" - I see. How do I use a "prefix arg"? This has no effect <kbd>C-u</kbd> <kbd>C-x</kbd> <kbd>f</kbd>.
    – buhtz
    Sep 19 at 19:31
  • 1
    After C-u, do M-x and type dired. It will ask you the options to use.
    – Renato
    Sep 19 at 19:48
2

Bind a key to dired-omit-mode (you may need to require dired-x first) and set dired-omit-files something like this:

(setq dired-omit-files
    (rx (or (seq bol (? ".") "#")     ;; emacs autosave files
        (seq bol "." (not (any "."))) ;; dot-files
        (seq "~" eol)                 ;; backup-files
        (seq bol "CVS" eol)           ;; CVS dirs
        ))
2
  • dired-omit-mode can hide files by name regexp match, or by file extension, so yes, you could use option dired-omit-files (a regexp) to have dired-omit-mode omit files whose names begin with ..
    – Drew
    Sep 19 at 22:09
  • @Drew: you are right. Have edited accordingly. Sep 20 at 10:22

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.