Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close the next window in Vim

Tags:

vim

Since I have a vertical split, how can I close the left window while the cursor is on the right window? I know I can go to the next window with Ctrl-w w and then close it but there might be a faster way. Thanks

like image 693
isar Avatar asked Dec 19 '22 12:12

isar


2 Answers

:-q or :-q! should do the job.

According to :h CTRL-W_q:

:q[uit]
:{count}q[uit]
...
                If [count] is greater than the last window number the last
                window will be closed:
                    :1quit  " quit the first window
                    :$quit  " quit the last window
                    :9quit  " quit the last window
                            " if there are less than 9 windows opened
                    :-quit  " quit the previews window
                    :+quit  " quit the next window
                    :+2quit " quit the second next window

I presume previews window above should read previous window...

like image 109
Sato Katsura Avatar answered Dec 22 '22 00:12

Sato Katsura


If you have only two windows open, the key combination Ctrl-w o (or the command :only) will close the next (and only other) window.

In general, Ctrl-w o closes all windows except the current window.

like image 35
Rory O'Kane Avatar answered Dec 22 '22 01:12

Rory O'Kane