I have mapped for convenience:
" this is a ctrl + backslash binding to vsplit
nmap <C-\> :vsplit<CR>
" this is a ctrl + hyphen binding to hsplit
nmap <C-_> :split<CR>
This is good but needs one more final touch to behave the way I want which is that it should focus the newly created window so I can immediately open up whatever file I want in it using traditional :e
or CtrlP plugin. As it is now, doing that is going to navigate from the original window which is slightly disorienting.
How can I get :split
and :vsplit
to auto-focus the newly created vim window?
To move between splits first press Ctrl-w (I remember this by Control Window, I'm not sure what the official mnemonic is) Then press a directional key to move the cursor to the split you're interested in. Directional key could be the arrows or my preferred home row method.
Control + W followed by W to toggle between open windows and, Control + W followed by H / J / K / L to move to the left/bottom/top/right window accordingly, Control + W followed by Left / Down / Up / Right arrow to move to the left/bottom/top/right window accordingly.
When I open the new split my cursor is automatically focused in the new window by default. What you probably don't realise is that the new vertical split is put on the left and the new horizontal split is put on the top.
To open new splits on the right or on the bottom of the screen add the following to your vimrc.
set splitbelow
set splitright
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With