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")
@Maurits2014 Thanks for your reply!!!
is this support to vi editor? i have added these line in my (/etc/virc)
"Turn on backup option
set backup
"Where to store backups
set backupdir=~/.vi/backup//
"Make backup before overwriting the current buffer
set writebackup
"Overwrite the original backup file
set backupcopy=yes
"Meaningful backup name, ex: [email protected]:59
au BufWritePre * let &bex = '@' . strftime("%F.%H:%M:%S")
i am testing it in vi editor only... i need to take a file backup before/after changes with the unique name for example:
if a file name is httpd.conf
before editing httpd.conf-date-before
after editing httpd.conf-date-after
is this possible?