Perhaps you can make use of H
, M
, or L
.
These keys jump the cursor to display lines:
H "Home" top of screen
M "Middle" middle of screen
L "Last" last line of screen
With a count, they offset: 4L
would go to the third line above the last (1L
is the same as just L
).
Personally, I make heavy use of the m
command to mark a line for navigation. From where I am now, hit mq
to mark the position with label q
; then navigate to another line, and ma
to mark it with label a
; and from then on I can hit 'q
to jump to position q
and 'a
to jump to position a
. (q
and a
are arbitrary; I use those mostly due to their position on a QWERTY keyboard.)
One you have the marks, you can use them for commands. To delete from the current position to the line marked with q
, you just use: d'q
There is a variant, where instead of single quote you use back quote. This takes you to the exact position on the line where you placed the mark; the single quote uses the start of the line.
Those marks work even for ex
(command line) commands. To limit search and replace to a specific set of lines, I mark the beginning and end lines respectively with labels b
and e
, and then do my search and replace like so:
:'b,'es/foo/bar/g