Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Last active December 25, 2022 22:03
Show Gist options
  • Select an option

  • Save jamescherti/14a87b56e6e72e8eccd90e7d28cb73f1 to your computer and use it in GitHub Desktop.

Select an option

Save jamescherti/14a87b56e6e72e8eccd90e7d28cb73f1 to your computer and use it in GitHub Desktop.
Vim: Save all modified files when the focus is lost.
" 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