2

Background: I'm working on a large project that has some disparate coding styles. I'm working on unifying that but only the parts that I've most recently touched.

The tool that I'm using produces a diff file, so I can do:

 black --diff <filename> >/tmp/patch

And then

 :diffp /tmp/patch

Which works great! I can ]c and [c to navigate my changes and do to get the ones that I want. The only problem is that I end up with this garbage myfile.new living in my pwd.

I couldn't find anything in :help :diffp that suggested there was any good way to say, "Okay, I'm done now, go away other file!"

The closest thing I found was this answer - :call delete(expand('%')) | bdelete!. This does exactly what I want. I could bind this of course, but I'm wondering...

Is there a better way? Should I just add nnoremap <leader>rm :call delete(expand('%')) | bdelete!<cr> or something to $MYVIMRC?

  • Vim open patched buffer (myfile.new) with notedited flag by default (check it with c-g or :f), it's only a buffer, not a real file yet, did you manually save the file? – dedowsdi Jun 13 at 0:01
  • wa won't save file which has noteditedflag unless it's modified. – dedowsdi Jun 13 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.