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?
2 Answers
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.
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
-
It'd be cool if you could toggle splits, like zoom in Tmux. Anyone know if that's possible?– domi91cCommented Feb 19, 2017 at 7:52
-
1
-
Does "close" here mean closing the buffers (equivalent of
:q
) or just hiding them? Commented Jan 16, 2019 at 15:21 -
@stillanoob I think they're closed, as
:tabs
doesn't show them.– kenorbCommented Jan 16, 2019 at 17:58