Hello,
I have a sample file with 7 lines, which is put to a Vim list,
"lines":
------------------------
idle -- line 1
idle -- line 2
if -- line 3
if -- line 4
if -- line 5
iff -- line 6
ill -- line 7
------------------------
What I want is two numbers with the pattern starting with "if":
(1) find the start line, 3 in this example
(2) find the end line, 5 in this example
For (1), it is straightforward:
let pat = '^' . 'if' . '\s\+'
let start = match(lines, pat)
But, it is not easy to figure out the 2nd position (I tried this)
let pat_test = '^' . 'if' . '\...@!'
let end = match(lines, pat_test, start)
Any idea to accurately locate the 2nd position?
BTW, I can achieve my goal with the following loop, but it takes
long ...
while next_matched > 0
let counts += 1
let next_matched = match(lines, pat_test, start, counts)
endwhile
Thanks
Sean
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---