Vim close window without closing buffer

A window is a viewport on a buffer. In vim to manage windows it is CTRL+w the leading command, that you can follow with several options (in bold those that answer to your question):

CTRL+w, v: Opens a new vertical split

CTRL+w, s: Opens a new horizontal split

CTRL+w, c: Closes a window but keeps the buffer

CTRL+w, o: Closes other windows, keeps the active window only

CTRL+w, right arrow: Moves the cursor to the window on the right

CTRL+w, r: Moves the current window to the right

CTRL+w, =: Makes all splits equal size

Then, you need to switch the buffers in the windows:

:ls lists all opened buffers

:b5 switches to your 5th buffer

Finally, to open all buffers in a vertical split, use: :vertical sball.
Very useful when you open multiple files as buffers after a grep:

grep -rno --exclude-dir={dir1,dir2,dir3} "searchterm" *
vim $(!! -l)

For more info, see the doc: vimdoc.sourceforge.net

Leave a Comment

tech