tags:

views:

330

answers:

5

Hello,

Vim's multilayered views (Windows, Buffers and Tabs) left me a little confused. Let's say I split the display (:sp) and then select a different buffer to display in each window. Now I want to close one of the buffers, yet I don't want the window to close (After the closing it can display the next buffer on the list or an empty buffer, it doesn't matter). How can I do this?

Thanks.

A: 

use ":bd" as a command.

Silvanus
This closes the window.
Mosh
A: 

Would

:enew

do what you want? it will edit a new, unnamed buffer in the current window leaving the existing file open in any other windows.

mikej
This will open a new empty buffer. I want to close the current buffer without closing the window.
Mosh
A: 

I think this is what you're looking for

http://www.vim.org/htmldoc/windows.html#window-moving

Try this:

Look ar your buffer id using

:buffers

you will see list of buffers there like

1  a.cpp
2  b.py
3  c.php

if you want to remove b.py from buffer

:2bw

if you want to remove/close all from buffers

:1,3bw
Casey
I don't want to move the window. I want to close the buffer without touching the window's position, size or existance.
Mosh
A: 

I don't think there is a one shot way to do this, but you could do :enew or :ls to list your buffers and swap to a different one using :b [number].

Once you've got a different buffer in the window :bd # will delete the previous buffer in the window, and since the current buffer still exists the window won't be closed.

Andrew Khosravian
+3  A: 

There's a script on the Vim wiki to do this. I don't think there is a builtin that does what you want.

Brian Carper
Great answer, it led me to the final version of the script on: http://www.vim.org/scripts/script.php?script_id=1147
Mosh