aboutsummaryrefslogtreecommitdiff
path: root/vim/config/swapfile.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-11 01:07:14 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-11 01:07:14 +1300
commitaaf04871d944646225875d5e9cc31a967947c3fe (patch)
tree787efb73dabb6b9cda660ccde51e838b507a3dbd /vim/config/swapfile.vim
parentMerge branch 'hotfix/v0.12.2' (diff)
parentBump version number to 0.13.0 (diff)
downloaddotfiles-0.13.0.tar.gz (sig)
dotfiles-0.13.0.zip
Merge branch 'release/v0.13.0'v0.13.0
* release/v0.13.0: (30 commits) Bump version number to 0.13.0 Move mutt_mail.vim line select logic into plugin Add new mail_mutt.vim plugin, apply mappings Sort 'shortmess' flag settings alphabetically Add 'o' and 'O' back into 'shortmess' Set up individual flags for 'shortmess' Fix oii(1df) so it works as a pipe Use exists+ test rather than exists& Adjust some whitespace and comment layout Move matchit.vim sourcing into plugin.vim Rename netrw.vim to plugin.vim Remove 'shellslash' setting Move fedora.vim into os.vim Remove 'tildeop' setting Rearrange three smaller files into display.vim Move 'paste' options into terminal.vim Move wildmenu config into completion.vim Rename complete.vim to completion.vim Rename term.vim to terminal.vim Rename yank.vim to registers.vim ...
Diffstat (limited to 'vim/config/swapfile.vim')
-rw-r--r--vim/config/swapfile.vim44
1 files changed, 13 insertions, 31 deletions
diff --git a/vim/config/swapfile.vim b/vim/config/swapfile.vim
index 778ae2f0..bf91aa6b 100644
--- a/vim/config/swapfile.vim
+++ b/vim/config/swapfile.vim
@@ -1,32 +1,14 @@
-" Swap files are used if using Unix and not using sudo(8); I very seldom need
-" them, but they are occasionally useful after a crash, and they don't really
-" get in the way if kept in their own directory
-if !strlen($SUDO_USER) && has('unix')
-
- " Use swap files but keep them in ~/.vim/swap; the double-slash at the end
- " of the directory prods Vim into keeping the full path to the file in its
- " undo filename to avoid collisions; the same thing works for undo files
- set swapfile
- set directory^=~/.vim/swap//
-
- " Create the ~/.vim/swap directory if necessary and possible
- if !isdirectory($HOME . '/.vim/swap') && exists('*mkdir')
- call mkdir($HOME . '/.vim/swap', 'p', 0700)
- endif
-
- " Don't keep swap files for files in temporary directories or shared memory
- " filesystems; this is because they're used as scratch spaces for tools
- " like sudoedit(8) and pass(1) and hence could present a security problem
- if has('autocmd')
- augroup dotfiles_swap_skip
- autocmd!
- autocmd BufNewFile,BufReadPre
- \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
- \ setlocal noswapfile
- augroup END
- endif
-
-" Otherwise, don't use swap files at all
-else
- set noswapfile
+" Default to no swapfile files at all, in a way that even ancient/tiny Vims
+" will understand; the auto_swapdir.vim plugin will take care of this
+set noswapfile
+
+" Don't keep swap files from temporary directories or shared memory in case
+" they're secrets
+if has('autocmd')
+ augroup dotfiles_swap_skip
+ autocmd!
+ autocmd BufNewFile,BufReadPre
+ \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
+ \ setlocal noswapfile
+ augroup END
endif