zzz2991
zzz2991

Reputation: 757

How can I switch windows in Vim

I am using Vim and I am unable to switch to one of my windows by using the default bind keys <ctrl+w> j. I have three windows open and the bottom right window is inaccessible. Why is this happening?enter image description here

Upvotes: 10

Views: 15300

Answers (2)

Matt
Matt

Reputation: 1122

It appears as if you have taken something similar to the following course of action

vim <some-file>
:vs <some-other-file>
<C-w> l     // to get to the right window
:term       // to open up a terminal session within right right window
<C-w> j     // to move to the bottom right window (a normal vim window)
:q
vim <file>  // within the terminal inside the right vim window
:sp <file>  // split that window

Now it will appear as if you have three vim windows, when in reality, you have four:

  • Two outer (the left, and the right terminal session)
  • Two within the right window's terminal session

This is quite a precarious position because whether you are in the outer left or right session, the outer buffer (not sure if this is the correct word so please correct me if I'm wrong) will always captures the <C-w> control character for some reason.

You can see this by looking where the <C-w> shows up on the screen when you press it. If I have replicated your environment correctly, it shows up in the bottom right corner below the outer buffer's right window.

As a workaround to this, instead of using <C-w> to proc window navigation, you need to use:

:winc j

to navigate to the bottom right window.

Upvotes: 6

NM Pennypacker
NM Pennypacker

Reputation: 6942

<ctrl> + w + w works for me.

If you :sp or :vsp to split a pane, <ctrl> + w + w will allow you to navigate between them.

Upvotes: 10

Related Questions