vim search and replace using current line as reference point

vim

Solution

You can use `.` for the current position, and `.+10` for 10 lines down:

:.,.+10s/foo/bar/g

Some other useful ranges:

- `%` for the whole file. Example: `:%s/foo/bar/g`.

- `'<,'>` for the lines of visually selected block. This might get you more than you want of the visual selection starts or ends in the middle of a line. The whole line is included.

- `'a,'b` from mark a to mark b.

- `.,$` from the current line to the end of the file.

Problem

Is there a way to specify search and replace range using the current line as a reference? I can specify range using explicit line numbers like ``` :5,15s/foo/bar/g ``` to do the search and replace on only lines 5 to 15. How to specify a range like "from the current line to 10 lines below (or above) the current line"?

Original source