Juniper Belmont
Juniper Belmont

Reputation: 3564

When I close a window in Vim, how do I change the window my cursor moves to?

I often have several windows open at once in Vim: one is my code, one is a side-bar, one is the open quickfix window on bottom.

Whenever I close the bottom window with <C-W> C, the cursor is moved to the side-bar, as it is on the left.

Is there a way I can make the cursor instead move to the main window on the right?

Upvotes: 0

Views: 106

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172520

You could remap the close command to always go back to the previous window:

:nnoremap <C-w>c <C-w>c<C-w>p

Upvotes: 3

Kent
Kent

Reputation: 195029

You said that the bottom window is quickfix. You don't have to move your cursor to that window, then type C-W c to close it. You could leave your cursor in your main window (above one), then :cclose, the quickfix window gets closed, and your cursor stays in where it was.

:h cclose to see detail. also you could make a mapping for that if use that often.

I am not sure if you would accept this.

Upvotes: 1

Related Questions