Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Stop Cursor Moving When The Page Scrolls

It happens to me many times that I want to look at other parts of the code while writing a statement, but whenever I scroll the page and the cursor reaches the bottom or top of the page it starts scrolling with the page, which means I have to search for the line I have been writing in. This is really annoying. Any idea if this can be disabled or not?

like image 645
Rafid Avatar asked Apr 30 '26 20:04

Rafid


2 Answers

It can't be disabled, but if you were writing a statement and want to get quickly back to where you were, just hit gi and you'll get back to where you were doing your last insert.

like image 99
dmedvinsky Avatar answered May 02 '26 11:05

dmedvinsky


Another useful vim trick is setting marks. m{a-zA-Z} set a mark {a-zA-Z} at cursor position. You can then send the cursor (and the window) back there by `{a-zA-Z}.

like image 24
ajwood Avatar answered May 02 '26 11:05

ajwood



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!