25

Ctrlw1w switches to the first window.

If currently I frequently edit in two of several windows, a shortcut for switching back to the last active window would be perfect.

Is there such a shortcut?

Teun Zengerink
  • 4,277
  • 5
  • 30
  • 32
user861746
  • 541
  • 2
  • 9
  • 14
  • "last" window or "latest" window? Did you try [this answer](http://stackoverflow.com/a/6404246/546861)? – romainl Apr 02 '13 at 18:41

3 Answers3

55

did you try

<c-w><c-p>

?

from help:

CTRL-W p                    *CTRL-W_p* *CTRL-W_CTRL-P*
CTRL-W CTRL-P   Go to previous (last accessed) window.

                        *CTRL-W_P* *E441*
CTRL-W P    Go to preview window.  When there is no preview window this is
        an error.
        {not available when compiled without the |+quickfix| feature}
Kent
  • 189,393
  • 32
  • 233
  • 301
8

As Kent said <c-w><c-p> will go to previous

You can also navigate between windows using the directions h, j, k, and l

<c-w><c-h>
<c-w><c-j>
<c-w><c-k>
<c-w><c-l>

<number><c-w><c-w> will navigate to a specific window

JupiterP5
  • 318
  • 1
  • 10
5

You can build your own short mapping; Vim is infinitely flexible in this regard. For example, many find these useful:

:noremap <C-j> <C-w>j
:noremap <C-k> <C-w>k
:noremap <C-h> <C-w>h
:noremap <C-l> <C-w>l

Also, learn how to look up commands and navigate the built-in :help; it is comprehensive and offers many tips. You won't learn Vim as fast as other editors, but if you commit to continuous learning, it'll prove a very powerful and efficient editor.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • I have those mappings too. it is so convenient. though it used `` I tried to mapp ` to something else` in terminal (urxvt), didn't make it.... – Kent Apr 02 '13 at 19:49