Matt
Matt

Reputation: 4989

mapping control followed by two characters in vim

I like switching my focus back and forth between the NERDTREE pane and a file and the command Ctrl-ww accomplishes this. I'd like to map this to <Leader>w but variations of map <Leader>w <C-ww><CR> in my .vimrc are not working for me. Any thoughts on how to accomplish this mapping?

Upvotes: 6

Views: 3663

Answers (1)

romainl
romainl

Reputation: 196516

It's not <C-ww>, it's <C-w>w or <C-w><C-w>.

That's either Ctrl+w then w or Ctrl+w then Ctrl+w.

So your mapping should be nnoremap <Leader>w <C-w>w or nnoremap <Leader>w <C-w><C-w>.

Note that you can use <C-w>p to move to the previous window and effectively toggle between NERDTree and your active window.

See :help window for more infos on windows in Vim.

Upvotes: 16

Related Questions