Kyle Ross
Kyle Ross

Reputation: 55

Vim start searching from current line

In vim, if I am at a specific line (A function signature) I would like to be able to search starting from the current line position to find "search" in the body of the function

Looking for this the answer appears to be Ranges:

:.,$/search

This does not work as expected as I find "search" at the top of the file

Upvotes: 2

Views: 1096

Answers (1)

user5069935
user5069935

Reputation:

By default just

/search<enter>

When entered in command mode will begin searching from your current cursor position downwards until it finds the next instance. To reverse the search direction use "?" instead of "/" in that command.

EDIT: Also, after entering that command once, repeatedly pressing n or N will cycle forwards or backwards through the search instances in the whole file. If you fall off the bottom of the file it will wrap around to the start again.

Upvotes: 5

Related Questions