Vertical line alignment when opening a new window in vim

How to maintain vertical alignment when opening a new window (split) under the current one in vim?

When I edit the file, some lines are visible (say 1-20). As soon as I open another window, the visible lines change to something else (say 5-15). I would like the original window to be aligned vertically, which means that lines 1-11 are shown in my example.

+3
source share
1 answer

The vertical alignment changes because Vim tries to keep the line that your cursor is currently on. The easiest way to do what you want is to simply click Hbefore you start splitting. Hmoves the cursor to the top line of the window, so when you split the viewport, you don’t have to change to keep the cursor in view.

This will move the cursor, but you can simply click ``to return to the character that was set when pressed H.

+2
source

All Articles