I always forget to save all the files in buffer before compile using the vim build-in compile command :make. So is it possible to make vim print a hint about save file just like what it does when we quit before saving files?
I always forget to save all the files in buffer before compile using the
Share
Edit Re:
You can use QuickFixCmdPre:
This example will save files on doing make. See for more info
:he autocmd.Of course, this will only work if you use vim’s
If you use other programs, don’t use e.g.
:!scons -C src, but instead use:se makeprg=scons\ -C\ srcand regular:maketo trigger all builtin Quickfix functionality.For more flexible auto-writing, see :
`
autowrite`I just use
in my .vimrc; This is actually quite safe, you’ll get warned whenever you risk losing changes either in-buffer or on-disk.
This is also pretty sweet when working on windows, simultaneously having the same file open in another program (say, Visual Studio or Notepad++; both can be configured to autoreload files on change as well).
The best part about this is that it will autosave also on minimize, so whenever you hit C-z to minimize, the file will be written (assuming it wasn’t changed on disk as well), and when you restore the window (or foreground it, in a terminal context) you’ll automatically get the most up-to-date file contents.