Next: , Previous: , Up: Common requests   [Contents][Index]

5.37 How do I disable backup files?

You probably don’t want to do this, since backups are useful, especially when something goes wrong.

To avoid seeing backup files (and other “uninteresting” files) in Dired, load dired-x by adding the following to your init file (see How do I set up an init file properly?):

(with-eval-after-load 'dired
  (require 'dired-x))

With dired-x loaded, C-x M-o toggles omitting in each dired buffer. You can make omitting the default for new dired buffers by putting the following in your init file:

(add-hook 'dired-mode-hook 'dired-omit-mode)

If you’re tired of seeing backup files whenever you do an ‘ls’ at the Unix shell, try GNU ls with the ‘-B’ option. GNU ls is part of the GNU Fileutils package, available from https://ftp.gnu.org and its mirrors (see Where can I get other up-to-date GNU stuff?).

To disable or change the way backups are made, see Backup Names in The GNU Emacs Manual.

You can control where Emacs puts backup files by customizing the variable backup-directory-alist. This variable’s value specifies that files whose names match specific patterns should have their backups put in certain directories. A typical use is to add the element ("." . dir) to force Emacs to put all backup files in the directory dir.