1

In vim, I am using Ctrl-w w to toggle between split windows. However, this toggling goes in one direction only. i.e., usually left to right in a cyclic manner.

When there are a large number of split windows, it takes a lot of effort to switch to the window immediately to the left. Are there any shortcuts to switch windows in the opposite direction?

SKPS
  • 5,433
  • 5
  • 29
  • 63

3 Answers3

5

(I assume you mean you are repeating the command, eg ctrl-w ctrl-w.)

Use the standard h, j, k, and l movement keys, eg:

  • ctrl-w h - select pane to the left
  • ctrl-w j - select pane below
  • ctrl-w k - select pane above
  • ctrl-w l - select pane to the right
tvon
  • 1,513
  • 1
  • 12
  • 16
1

Use Ctrl+W followed by one of hjkl to move to the desired direction.

I've put a map into my .vimrc that goes like this:

map <C-J> <C-W>j

to ommit the Ctrl+W stroke.

ohcibi
  • 2,518
  • 3
  • 24
  • 47
  • I use the same approach. The only issue I had to deal with was that I was used to press `` to redraw the window. Solution is easy: `noremap l` moves me to the left window _and_ redraws the windows. – Ikar Pohorský Aug 14 '13 at 11:33
1

You don't need to hit <C-w> twice, keeping the Ctrl key pressed and hitting w twice works just as well. You don't even need to keep the Ctrl key pressed, actually: <C-w>w is the exact equivalent of <C-w><C-w>: hit <C-w> then hit w.

That said, the opposite of <C-w>w is simply <C-w>W (uppercase W, same logic as :bn/:bN or gt/gT).

See :help window-move-cursor.

romainl
  • 186,200
  • 21
  • 280
  • 313