Search offsets
Sometimes, the line that you’re actually looking for is a few lines above or below the line that you’re searching for. If this is the case, you can use a search offset to change where you’ll land.
There are two types of search offsets: line offsets and character offsets. Line offsets are generally more useful, so we’ll focus on them for now. For line offsets, there are two things to remember:
- prefixing your search with
/+10will offset your search by ten lines downwards - prefixing your search with
/-10will offset your search by ten lines upwards
For example, to land ten lines above the next line containing NEEDLE, you’d type /NEEDLE/-10, followed by enter, in normal mode.
Let’s try this in the editor. There’s a special string hidden 300 lines above the NEEDLE in the editor. See if you can find it using a search offset!