I know there's probably a very good reason for it (i.e. backup) - but for personal reasons (it's just annoying me), is it possible to stop emacs from creating a backup of every file I edit? I'm talking about when it creates a file appended with the ~ character.

FooBar
FooBar~
HelloWorld
HelloWorld~
link|improve this question

59% accept rate
feedback

3 Answers

up vote 5 down vote accepted

Put in your .emacs file.

(setq make-backup-files nil) ; stop creating ~ files

What the variable does...

make-backup-files is a variable defined in `files.el'.

Non-nil means make a backup of a file the first time it is saved. This can be done by renaming the file or by copying.

Renaming means that Emacs renames the existing file so that it is a backup file, then writes the buffer into a new file. Any other names that the old file had will now refer to the backup file. The new file is owned by you and its group is defaulted.

Copying means that Emacs copies the existing file into the backup file, then writes the buffer on top of the existing file. Any other names that the old file had will now refer to the new (edited) file. The file's owner and group are unchanged.

I prefer to have the files backed up into 1 directory ~/.Trash/.

(setq backup-directory-alist            '((".*" . "~/.Trash")))
link|improve this answer
I tried setq backup-directory-alist but it did not work. – nbolton Dec 16 '09 at 17:57
It depends upon your emacs version, make sure it exists. How did you configure the variable in your .emacs? – Darren Hall Dec 16 '09 at 18:53
feedback

I googled "emacs backup files", and the #2 hit was "Preventing the Creation of Backup Files".

:-)

link|improve this answer
Damn! Man do I feel stupid... ha. – nbolton Dec 16 '09 at 17:51
404 - page not found. – noahz Nov 13 '11 at 23:05
feedback

This will not stop the creation of backup files but may take away your issues with them.

Personally I just ignore the backup files for these reasons:

  • The backup files are generally ignored by version control clients.
  • ido-mode (ido-find-file) ignores the backup files during file selection unless you specifically type '~' into the search. So you don't even notice them.
  • Using dired you can mark all your backup files for deletion using '~' key and then 'x' to delete them in bulk.
  • Many GUI file managers ignore the backup files.

These reasons mean that I don't even notice the backup files, unless it comes to the point where I actually need them.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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