Sunday, June 20, 2021

Search for pattern in the first few lines of a buffer

I need to programmatically search for a pattern in the first ten lines
of a given buffer, and save the match in a variable when found. Say, the
pattern is:

% KEY = value

I need to extract the value if the above appears in the first lines of
the buffer. Of course, the state of the buffer's window, such as the
cursor's position, etc., and the content of registers should not be
affected. How would you do that?

Thanks,
Life.

--
--
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/san735%24vqe%241%40ciao.gmane.io.

No comments:

Post a Comment