This happens when I open an anonymous scratch file, and then do a :wa
even if I close the buffer.
Esc + Shift ZQ (Exit without saving) Now it is really up to you to choose how you want to quit the Vim editor. If you ask me, the first method is what you should opt for. You save (without exiting) with :w command and then you can use :wq to save and quit (w for save and q for quit). It is easier to remember q for quit.
When 'fileformats' is empty, there is no automatic detection. Dos format will be used. is done. This is based on the first <NL> in the file: If there is a used. All this, however, happens only in Vim "for Windows".
If you are feeling a little low because you didn’t know how to quit Vim, don’t, because you are not the only one. According to Stack Overflow, over a million developers worldwide searched for how to exit Vim. In fact, exiting Vim has become a talking point in the popular culture. Take this tweet, for example.
:wq – Save the file and exit Vim. Once you have made your choice of the exit command, press enter to finally quit Vim and close the editor (but not the terminal). Do note that when you press “: ” the editor will have the next keystrokes displayed at the bottom left of the terminal.
Your own answer is just curing the symptoms, not tackling the root cause.
It's better to properly indicate to Vim that your "scratch buffer" (which I guess is just by convention for you) is not meant to be persisted. That's what the 'buftype'
option is for. Open a scratch buffer with this (or create a corresponding mapping or command):
:new +setl\ buftype=nofile
so you either need to save the buffer (and give it a name)
or since it's a scratch file, if you're done with it you need to force vim to delete it properly:
:b nn " where nn = the errant buffer
:bd! " kill the scratch file
use :h bd
for more info
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