Whenever Emacs saves a file, it makes a backup of the original.
So if I had a
file.txt and I make changes and save it, Emacs firsts backs up the original to
While I love this functionality, and it has saved me from a pickle more than once, I don’t love the way my folders get polluted with
~ files all over the place.
My blog’s drafts folder had hundreds of these.
Mercifully, Emacs offers a way to stow all these files in one central folder of your choosing.
All I did was add this little snippet to my
;; Set the folder for backup files to a subfolder in the ;;.emacs.d folder of the user. (setq backup-directory-alist '(("." . "~/.emacs.d/file-backups")))
Emacs now stops littering all over the place and saves the backups it creates, to a `file-backups` folder in my `.emacs.d` folder. You can choose a location, you like better :)