How do I keep vertical alignment when opening a new window (split) under current one in vim?
When I edit a file, some lines are visible (say 1-20). Once I open another window the visible lines change to something else (say 5-15). I would like to keep the original window vertically aligned, meaning see lines 1-11 in my example.
The "vertical alignment" changes because Vim is trying to keep the line that your cursor is currently on in view. The simplest way to do what you want is just to press H before you do your split. H moves your cursor to the top line of the window, so when you split the viewport won't have to change to keep your cursor in view.
This will move your cursor of course, but you can just hit `` to return to the mark that was set when you pressed H.
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