2

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 2

4

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

1
  • This gets rid of the visual mode, which is great and better! Commented May 18, 2022 at 12:03
0

It turns out this can fit my requirement:

vim.cmd("exe 'normal! V'")
vim.cmd("/\\%V"..input)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.