Hiding Files From Dired Display

Emacs Elements has a short video that explains something I didn’t know. You can tell Dired to not display certain files. My first thought was, “Why would I want that?” After all, if you have a file you probably want to know it’s there when you list a directory.

The justification from the video is that Emacs Elements main computer runs Windows and that OS adds a lot of files and directories whose purpose you may not even know. I was in the middle of feeling sorry for Windows users when I realized that macOS does the same thing and, sure enough, I don’t know what many of them are for.

My mental firmware automatically filters them out so I’m barely aware of them but if the idea of all these files that you never interact with bothers you and you’re a Dired user, the answer is simple. You simply add the file you want to omit to the dired-omit-files variable. It’s a regular expression so you can add file patterns if you need to. On my Emacs, it’s already set to omit ., .., auto-save files, and lock files.

The variable has effect only when dired-omit-mode is t. If you really want to see everything in the buffer you can toggle the hiding with Ctrl+x Meta+o.

The video is only 3 minutes, 34 seconds so you’ll have no problem fitting it in. The problem it describes is a small thing but there’s no reason to clutter up your directory listings and your mind with junk you don’t care about.

This entry was posted in General and tagged . Bookmark the permalink.