How do I land on a specific position relative to a search match?
Answer
/pattern/e
Explanation
Search offsets let you place the cursor at a specific position relative to the match. The /e offset places the cursor at the end of the matched text instead of the beginning.
How it works
/pattern/eplaces the cursor at the end of the match/pattern/e+1places it one character after the end/pattern/b+3places it 3 characters from the beginning/pattern/+2places it 2 lines below the match
Example
Searching for function in:
function calculateTotal(items) {
/functionlands onf/function/elands onn(end of "function")/function/e+1lands on the space after "function"
Tips
- These offsets work with
?(backward search) too /pattern/-1positions one line above the match- Offsets are remembered for
n/Nrepeats - Especially powerful with
:sfor targeted replacements