Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in vim, how to get rid of irritating "E141: No file name for buffer nn"

Tags:

vim

This happens when I open an anonymous scratch file, and then do a :wa

even if I close the buffer.

like image 799
ErichBSchulz Avatar asked Oct 08 '13 07:10

ErichBSchulz


People also ask

How do I exit Vim editor without saving?

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.

How to detect empty fileformats in Vim?

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

Did You Know you can Quit Vim?

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.

How do I Close a file in Vim?

: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.


2 Answers

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
like image 93
Ingo Karkat Avatar answered Nov 09 '22 21:11

Ingo Karkat


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

like image 21
ErichBSchulz Avatar answered Nov 09 '22 20:11

ErichBSchulz