32

Sometimes when I'm working on a file, I'll open up multiple files just to get an idea of the current flow of the code up to a point. However this sometimes leads to multiple files being open at a time by split. Is there a command to quit all except the selected window?

37

If you want to close all windows(splits) except the current one:

:only

If you want to close all tabs except the current one:

:tabonly

If you want to delete all hidden buffers (files open but not visible in any window on any tab), you'll have to add a function to your vimrc. Some people have posted possible functions to here and here

I'm not sure exactly which of these you were trying to accomplish, but hopefully some combination of these commands does the trick.

27

Press Ctrl+w,o to quickly close all split windows, but current one.

Alternatively use the command: :on (:only).

:on[ly][!] Make the current window the only one on the screen. All other windows are closed.

See also:

  • 2
    Ctrl+W,o <<< this should be accepted answer – Leo Jun 16 '16 at 14:26
  • It'd be cool if you could toggle splits, like zoom in Tmux. Anyone know if that's possible? – domi91c Feb 19 '17 at 7:52
  • 1
    @portOdin You need to ask another question then. – kenorb Feb 19 '17 at 11:53
  • Does "close" here mean closing the buffers (equivalent of :q) or just hiding them? – stillanoob Jan 16 at 15:21
  • @stillanoob I think they're closed, as :tabs doesn't show them. – kenorb Jan 16 at 17:58

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.