In my syntax file I have something likesyn match cleanReal [+-~]\?\<\d\+\.\d+\(E[+-~]\?\d+\)\? displayhi def link cleanReal FloatIs there a way to get all strings that are matched as cleanReal from vimscript?I'm asking because I would like to write a custom command completion function that completes all strings matched by some syntax group.
Get all syntax elements with some group name from buffer
vimscript;syntax highlighting;autocompletion
The last time I've tried something similar, it was to emulate ]s long before it existed. I proceeded by going from word to word until I find one with the right synId*() value.You could do that, but I'm afraid that it'll be very slow.If your syntax group it just a regex that you know, and with no context or whatever (like exclusion within comments or strings), may be the easier approach would be to get all matches from getline(1,'$')let text = join(getline(1,'$'), \n)let matches = []call substitute(text, yourregex, '\=add(res, submatch(0))', 'g')let matches = uniq(sort(matches))