Reputation: 20269
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?
Upvotes: 3
Views: 1544
Reputation: 17137
All you need is these key strokes:
zz , zt and zb
The cursor is on the same position, but your windows will move. ( in normal mode of course)
zz the cursor position is centered
zt the cursor position is at the top
zb the cursor position is at the bottom
Upvotes: 1
Reputation: 19057
I often split my window when I'm looking at more than one part of a file. :sp
for a horizontal split, and :vs
for a vertical split.
Upvotes: 2
Reputation: 19057
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}
.
Upvotes: 2
Reputation: 8356
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.
Upvotes: 3