3 ms·
It's impossible not to note that emacs does this well too. Setting (setq backup-directory-alist `(("." "/home/user/some/dir/you/chose/backup/)) ver
by kristjansson 5y ago
It's impossible not to note that emacs does this well too. Setting
(setq backup-directory-alist `(("." "/home/user/some/dir/you/chose/backup/))
version-control t
kept-new-versions 50
kept-old-versions 50)
sets up a directory with many versions of every file ever edited. Additionally
(setq auto-save-file-name-transforms `((".*" "/home/user/some/dir/you/chose/auto-save/" t)))
does the same for even unsaved changes.
- kazinator 5y agoVim doesn't do it "well" with the settings above, just "good enough". The time stamp suffix is calculated just once when you start Vim, set in the global backupext option. If we :e edit files in an existing Vim session, they all get backups with that time stamp. It needs to be calculated as a buffer-specific value of that option, if there is such a thing, on every new edit.
- kazinator 5y agoI just found that the Vim manual recommends, right in the doc for backupext, the use of the BufWritePre hook instead, so: :au BufWritePre * let &backupext=("." . strftime("%y-%m-%d.%H:%M:%S")) This has the right effect that every time you save with :w, a new backup is made of the previous contents.