Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make vim print hint about save the unsaved file before compiling?

Tags:

vim

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?

like image 892
Frank Cheng Avatar asked Dec 20 '11 13:12

Frank Cheng


People also ask

How do I save and quit all tabs in Vim?

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)

How do I save a buffer in Vim?

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?".

Where are vim buffers stored?

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.


1 Answers

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.
like image 128
romainl Avatar answered Oct 12 '22 07:10

romainl