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?
It's possible to suffix a[ll] for a number of Vim command-line commands (i.e. type : when in normal mode), include: :wa - save all tabs / unsaved buffers. :xa / :wqa - save all tabs / unsaved buffers and exit Vim. :qa - exit vim (will warn if unsaved buffers exist)
The :wa and :xa commands only write a file when its buffer has been changed. By contrast, the :w command always writes the current buffer to its file (use :update to save the current buffer only if it has been changed). Warning: If you enter :qa! , Vim will discard all changes without asking "are you sure?".
For example, when you start VIM without supplying a file for it to open, VIM starts with an empty buffer. If you want to save the changes to that buffer, then you have to tell VIM what file to write those changes to. So again, a buffer resides in memory.
Just create a simple mapping like:
nnoremap <leader>m :wa <BAR> :make<CR>
:wa
to write all buffers:make
to build|
between the two to execute the commands in sequence.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With