gnvim icon indicating copy to clipboard operation
gnvim copied to clipboard

Changes silently lost if the editor window is closed

Open alexeymuranov opened this issue 4 years ago • 4 comments

If i close the editor window with window close button, the changes in the open buffers are silently lost.

alexeymuranov avatar Oct 31 '21 09:10 alexeymuranov

You can fix this with configuration.

Add: ~/.config/nvim/init.vim

set autowriteall

Or if you want to protect against crashes too, also add:

augroup AUTOSAVE
  au!
  autocmd InsertLeave,TextChanged,TextChangedI,FocusLost * silent! write
augroup END

If you normally edit huge files, this might not be a good idea though, as there will be much autosaving there.

From :h 'autowriteall'

'autowriteall' 'awa'    boolean (default off)
                        global
        Like 'autowrite', but also used for commands ":edit", ":enew", ":quit",
        ":qall", ":exit", ":xit", ":recover" and closing the Vim window.
        Setting this option also implies that Vim behaves like 'autowrite' has
        been set.

maage avatar Nov 05 '21 15:11 maage

Thanks, this is better than nothing, but I would expect a confirmation dialogue to appear. Maybe changes were unintentional.

alexeymuranov avatar Nov 05 '21 16:11 alexeymuranov

If implementing confirmation dialogue is not yet planned, I think an acceptable workaround is to disable the window close button.

alexeymuranov avatar Nov 06 '21 09:11 alexeymuranov

Same as #147?

dbarnett avatar Jun 19 '22 00:06 dbarnett

Duplicate of #147.

vhakulinen avatar Nov 27 '22 12:11 vhakulinen