How do I close a single buffer (out of many) in Vim?

I open several files in Vim by, for example, running

vim a/*.php

which opens 23 files.

I then make my edit and run the following twice

:q

which closes all my buffers.

How can you close only one buffer in Vim?


A word of caution: "w does not stand for write but for wipeout!"

More from manuals:

:bd

Unload buffer [N] (default: current buffer) and delete it from the buffer list. If the buffer was changed, this fails, unless when [!] is specified, in which case changes are lost. The file remains unaffected.

If you know what you're doing, you can also use :bw

:bw

Like |:bdelete|, but really delete the buffer.


If this isn't made obvious by the the previous answers:

:bd will close the current buffer. If you don't want to grab the buffer list.


Check your buffer id using :buffers

you will see list of buffers there like

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

if you want to remove b.php from buffer

:2bw

if you want to remove/close all from buffers

:1,3bw
链接地址: http://www.djcxy.com/p/91702.html

上一篇: 从std:vector获取数组

下一篇: 如何关闭Vim中的单个缓冲区(多个)?