Last active
December 25, 2022 22:03
-
-
Save jamescherti/14a87b56e6e72e8eccd90e7d28cb73f1 to your computer and use it in GitHub Desktop.
Vim: Save all modified files when the focus is lost.
This file contains hidden or 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
| " Language: Vim script | |
| " Description: Save all modified files when the focus is lost. | |
| " Author: James Cherti | |
| " URL: https://gist.github.com/jamescherti/14a87b56e6e72e8eccd90e7d28cb73f1 | |
| " License: MIT | |
| function! SaveAll() abort | |
| let s:confirm = &confirm | |
| try | |
| set noconfirm | |
| silent! wall | |
| finally | |
| let &confirm = s:confirm | |
| endtry | |
| endfunction | |
| augroup SaveAllWhenFocusLost | |
| autocmd! | |
| autocmd FocusLost * call SaveAll() | |
| augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment