Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim cursor position on new split window

Tags:

vim

The default behaviour keeps the cursor on the original split window, so I have to press ctrl+w hjkl to switch to the new one. How can I set vim to to this automatically for me, whenever i open a new split pane?

like image 447
nam Avatar asked Sep 03 '26 23:09

nam


1 Answers

When you :split filename, the new window (containing filename) will be active. It's just that your perception of what is "original" differs from Vim's behavior when you :split / <C-w>s the current window into two.

You can influence Vim's behavior (for both same-buffer and different-file splits) with the following options:

:set splitbelow
:set splitright

If you just want to change the behavior for same-buffer splits, you have to override the default <C-w>s command with a mapping; there, you can use the :belowright split command to influence the behavior without modifying the mentioned options.

like image 100
Ingo Karkat Avatar answered Sep 05 '26 14:09

Ingo Karkat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!