Thursday, March 17, 2016

Start/end positions of all matches on a single line

I would like to know the start/end positions of matches on a few lines.
These linenumbers are in a list "list".
I want to add the startpositions of all matches in the list "idx"
and the endpositions of matches in the list "edx"

idx = []
edx = []
for n in range(0,len(list)-1)
"idx positions
call cursor(list[n],1)
while line(".") == list[n]
let S= searchpos(@/, '')
if S[0] == list[n]
call add(idx, S[1]-1)
endif
endwhile
"edx positions
call cursor(list[n],1)
while line(".") == list[n]
let E= searchpos(@/, 'e')
if E[0] == list[n]
call add(edx, E[1])
endif
endwhile

"do things with these lists before to go to next for loop (...add linenumber)
endfor

However this does not give an (idx) matchposition when the match is at the start of line.
Does anyone know how to catch all start/end positions of all matches of only 1 single line?

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: