On 02/09/09 19:24, Alessandro Antonello wrote:
>
> Hi, all.
>
> This is a simple question. Maybe I did not searched in the right place.
> Well, if you use the following command:
>
> :bd 5
>
> You will 'delete a buffer' that it's number is 5.
> The following command:
>
> :bd 3 5 7 9
>
> Will do the same for the buffers 3, 5, 7 and 9.
> And more:
>
> :1,4bd
>
> Will delete  from buffer 1  to 4.
> Why the  ':close' command  does not  have a similar functionality?  See,  I
> use  GVim usually with two or  more buffers in "splitted" windows.  I  don't
> want to change  to another window  just to close it.  I want  to close it from
> else where.  But the ':close'  command does not accept a buffer number or
> name.  What can I do?
>
> Regards,
> Alessandro

They don't act the same because they aren't parallel.

":bun[load]", ":bd[elete]" and ":bw[ipeout]" all act on _buffers_, each 
of which can be displayed in zero, one or several windows, and they all 
accept a buffer range before the command, space-separated buffer numbers 
after, or one (non-numeric) buffer name in cleartext. If any buffer you 
unload, delete or wipe happens to be displayed in one or more windows, 
_all_ windows displaying it will be closed as a side-effect, except that 
Vim itself won't close so at least one window (possibly empty, or 
possibly on a different buffer than before) will remain open after the 
command.

":clo[se]", OTOH, acts only on the _current window_, the way ":q[uit]", 
":x[it]" and ":exi[t]" do. If the current buffer is displayed in more 
than one window, all these commands will close _only_ the current one 
(or maybe they won't close anything and give an error message instead). 
Also, ":q" and ":x", but not ":close", can close the current window even 
if it is the only one, thus shutting down the current Vim instance.

What can you do? Use a different command.

If you want to close _all_ windows of _any_ tabs containing buffer 5, 
which is not 'modified' (maybe because you just saved it to disk, or 
maybe because you viewed it but did not alter it), use ":bun 5". This 
command accepts one or more buffer numbers, or one non-numeric buffer 
name, after it, or a buffer range before it, and that buffer (or any of 
those buffers if several) may, but need not, be the current one.

If you want to close the current window but not other windows containing 
the same buffer, you can use ":close", ":q" or ":x", but of course you 
cannot use the buffer number in that case, because it is common to the 
window you want to close and some others that you don't.

I fear you cannot close a non-current window (but not other windows on 
the same buffer) from elsewhere, but you can go to it, close it, and 
come back. Depending on circumstances, there are several ways to do 
that, see among others
        :help expand()
        :help CTRL-W
        :help :wincmd
        :help :drop

You may even want to write a user-command and/or function to automate 
the process, but beware that the window you started from won't 
necessarily keep its window number if you close another window. See
        :help :command
        :help :function

Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
134. You consider bandwidth to be more important than carats.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to