I found this :help window-move-cursor, but I tried to call it from the command line and doesn't work. Is there a way to change the key mapping for switch windows?


You can invoke any normal mode mappings via :normal!. The <C-w> used by the window movements is a challenge; you need :execute to evaluate the :help key-notation:

:execute "normal! \<C-w>j"`

However, there's the special :wincmd that simplifies the invocation; the above example becomes

:wincmd j

Now, if you want to change the key mappings, that can be done via :map:

:nnoremap <F7> <C-w>j

To add to the Ingo's answer here is a set of config that allows you to move to other panes using Control and a movement key.

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

The following works, it's an example in the help for the 'normal' command:

:exe "normal \<c-w>\<c-w>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.