I have vim set up to save empty files automatically when I create one:
autocmd BufNewFile * :write
And, I have the fugitive plugin for git installed. In fugitive :Gwrite will add the current file to git if necessary, and stage the changes to be committed.
What I would like to be able to do, is what PHP Storm does. If I add a file, it prompts me and asks me if I want to add it to git as well. So, ideally, I would like to type :edit some_new_filename, have it create the buffer, save the file, and then prompt if I want to add it to git. If I say yes, it should add it, and if I say no, it should not.
I have not seen any examples of prompts and responses in vim; so I honestly don’t even know if it’s possible. Is it, and if so, will you please help me with the syntax?
You can use the
confirmfunction to prompt the user for an answer:Then you call that function