简体   繁体   中英

switching windows with <leader> instead of ctrl

I recently start using leader key in vim, and mapped to space

Earlier I use window switching with ctrl + {h, j, k, l}

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

And now I was trying something like

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

I already remove any prior mapping with the above mentioned key.

Now issue I am facing is, with ctrl key i can switch the window panes without lifting finger from ctrl
While with space I have to press Leader and {h, j, k, l} simultaneously and then I have to press leader and {h, j, k, l} if want to go to some other window pane.

What I am trying to say is, let say my window vertically split b/w two and I wish to go to second window and come back to original.
With ctrl key: ctrl + l + h
with leader key: space + l, space + h

I want my leader key work exact same as ctrl, since it is convenient to use
Is this possible?

Also If you have some advice for newbie like me, I will be glad to hear it.

What you call "leader key" is not a special key at all and certainly not a modifier , like Ctrl , Shift , or Alt so you can't make it work like one. Unless they involve one of those modifiers, Vim mappings are always sequential: you press the first key, then the second one, etc.

If you absolutely want chord-like mappings, you could try arpeggio .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM