Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AysadKozanoglu/58afb2271d732e5ad713a9e247ce0373 to your computer and use it in GitHub Desktop.
Save AysadKozanoglu/58afb2271d732e5ad713a9e247ce0373 to your computer and use it in GitHub Desktop.
Using auto backup with Vim — First published in fullweb.io issue #3

Using auto backup with Vim

Not using versioning on your configuration files and editing them with Vim? Use Vim’s backup option to automatically keep a copy of past versions:

To put in your ~/.vimrc:

"Turn on backup option
set backup

"Where to store backups
set backupdir=~/.vim/backup//

"Make backup before overwriting the current buffer
set writebackup

"Overwrite the original backup file
set backupcopy=yes

"Meaningful backup name, ex: filename@2015-04-05.14:59
au BufWritePre * let &bex = '@' . strftime("%F.%H:%M")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment