tags:

views:

1069

answers:

8

I use Vim in Screen. I run the command

vim <bigFolder>

I am in stuck, since it does not make sense to close each buffer by

 :q

How can you close all active buffers in Vim, by one command inside Vim?

+12  A: 

:qall will close all windows

Ry4an
Thank you very much! You saved my day. My terminal would be useless without your command.
Masi
short version :qa
Otto Allmendinger
+3  A: 

That doesn't save the buffers though. Maybe :wqall! :xall! is a little better.

David Weitz
+7  A: 
:on

will close all buffers except the one you are currently editing (the cursor is inside this buffer).

:on!

will also close modified buffers but these will become hidden buffers.

:ls

will lists all the buffers with their status (hidden, ...)

Some help:

:h only
:h hidden-buffer
:h ls
Oli
Thank you for your answer! - - I cannot see the difference between the option [!] and without it. All my buffers just get hidden by both commands, even my saved ones. How can you see the difference?
Masi
I took this from the vim help and you're right, I don't see the difference between the two.
Oli
It seems that it is a mistake in the manual. Do you know where is the errata of Vim's manual? I could not find it by Google.
Masi
+1  A: 

If you happen to get VIM completely stuck you should still be able to kill it from outside VIM.

  • If you're able to suspend VIM with CTRL+Z, then you can kill it with kill %vim
  • If you can't suspend VIM you should be able to find its pid using ps. The you can kill it:
$ ps -f -C vim
UID        PID  PPID  C STIME TTY          TIME CMD
nfellman 27273  7473  0 Jun24 pts/15   00:00:00 /nfs/iil/home/nfellman/vim/bin/vim a.pl
nfellman 37213  23747 0 Jun23 pts/15   00:00:00 /nfs/iil/home/nfellman/vim/bin/vim b.pl

So if I want to kill the VIM that's editing a.pl you can do:

kill -9 27273

This should work even inside screen

Nathan Fellman
A: 

:q!

always works for me.

Sean McSomething
+10  A: 

The :bufdo command lets you execute a command on all buffers. In this case, you want to run :bufdo bdelete to close all open buffers in one go.

sunaku
A: 

:%bd(elete)

I think this is what you asking for

Ron
+1  A: 

:on does NOT close any buffers; it only closes the other windows.

bca