As title. The current problem is that my window is scrolled to the first/next(?) global occurrence. But I just want it to move my cursor to the local one, i.e. the current line, if any.
2 Answers
You can use the \%l
atom to restrict the search to the current cursor line, so in your case you probably want /<regex>\%.l
The .
before the l
is the shortcut to only search in the cursor line. See :h /%l
-
This gets rid of the visual mode, which is great and better! Commented May 18, 2022 at 12:03
It turns out this can fit my requirement:
vim.cmd("exe 'normal! V'")
vim.cmd("/\\%V"..input)