Created
November 22, 2017 14:18
-
-
Save gagbo/4650cd713974792cc8edc6e5bcd00ecb to your computer and use it in GitHub Desktop.
Properly manage swap files in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup SwapfileManagement " From a tpope snippet. | |
autocmd! | |
" The trick is that resetting 'swapfile' deletes the swapfile. | |
" The if is most likely for the cases when dir is nuked while editing | |
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave * | |
\ if isdirectory(expand("<amatch>:h")) | | |
\ let &swapfile = &modified | endif | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment