nam
nam

Reputation: 63

Vim cursor position on new split window

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?

Upvotes: 6

Views: 2045

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172688

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.

Upvotes: 13

Related Questions