aboutsummaryrefslogtreecommitdiff
path: root/vim/config/backup.vim
blob: 718647fc6d3e249d3cfbfb23c7d8c0d6209699f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
" Use backup features if on a UNIX-like system and not using sudo(8)
if !strlen($SUDO_USER) && has('unix')

  " Keep backups with a .bak extension in ~/.vim/backup; the double-slash at
  " the end of the directory is supposed to prod Vim into keeping the full
  " path to the file in its backup filename to avoid collisions, but I don't
  " think it actually works for backups, just undo and swap files
  set backup
  set backupext=.bak
  set backupdir^=~/.vim/backup//

  " This option already includes various temporary directories, but we
  " append to it so that we don't back up anything in a shared memory
  " filesystem either
  set backupskip+=*/shm/*

  " Create the backup directory if necessary and possible
  if !isdirectory($HOME . '/.vim/backup') && exists('*mkdir')
    call mkdir($HOME . '/.vim/backup', 'p', 0700)
  endif

" Don't use backups at all otherwise
else
  set nobackup
  set nowritebackup
endif