Friday, January 13, 2023

Searching across a range of lines

Hello,

I want to use something like search(), but only across a specific set of lines. The problem is that search() always starts at the current cursor line.

For example, I want to find a match for 'cat', but only in lines 50 to 100. If my cursor is before line 50 when I start, I can prefix my expression with \%>49 and pass 100 as the stopline, but that doesn't work if my cursor is AFTER line 50 as it starts the match at the cursor location.

I don't want to first move my cursor. I'm also hesitant to use getline() to grab all the lines, do an indexOf type search and then return the line number because that's going to get memory intensive if I have a large file.

Does anybody have any thoughts on this? I'd appreciate advice.

Thank you very much,

--
 
Salman

I, too, shall something make and glory in the making.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEdmGJyMwFkatS1SpDnaADOc%3D3fVN4zX%2BUMX6deBKAW3dQ%40mail.gmail.com.

No comments:

Post a Comment