2

I recently added set hidden to my vimrc script because I didn't always want to :write a file before :editing another file. (With set nohidden, which is the default, this resulted in a E37: No write since last change (add ! to override) error).

Setting hidden solved this problem, but introduced a new one. Sometimes, I split the window (ctrl-w n) before I :edit a file. This creates an empty buffer for each split that I have done. This is of course not what I want.

So, is there some setting or autocommand or anything that I am not aware of that gets rid of unused empty buffers automatically?

6

Cut out the middle man. If you want to edit a file in a split, use :split file.txt.

It is the very nature of using <C-W>n that creates these new buffers. It's like using the :new command, which is wasteful if you plan to immediately edit some other file.

If you like the visual confirmation of seeing the new window before editing the file, you could use <C-W>s which opens a split with the current buffer (so you'll see two of the same file) and then proceed to use :edit file.txt.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.