Skip to content

Instantly share code, notes, and snippets.

@unrealapex
Created June 15, 2022 04:29
Show Gist options
  • Save unrealapex/272c1adce1da579d57b424f5dd792dfe to your computer and use it in GitHub Desktop.
Save unrealapex/272c1adce1da579d57b424f5dd792dfe to your computer and use it in GitHub Desktop.
" auto save file when it is modified
augroup auto_save
autocmd!
" call save function
autocmd BufModifiedSet * call AutoSave()
augroup end
" save function that is called when buffer is modified
function AutoSave()
if (bufname() != "" && &buftype == "" && &filetype != "")
silent write
" prevent empty, readonly, etc... buffers from being saved
else
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment