Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created May 31, 2017 22:57
Show Gist options
  • Save tjdevries/8c1901061ae87d3466e3631a1c2bf152 to your computer and use it in GitHub Desktop.
Save tjdevries/8c1901061ae87d3466e3631a1c2bf152 to your computer and use it in GitHub Desktop.
searching syntax
function! TestStuff() abort
normal! gg
let g:res = []
while search('^\S', 'W')
call insert(g:res, {
\ 'name': expand('<cword>'),
\ 'line': line('.'),
\ },
\ len(g:res)
\ )
endwhile
normal! gg
let index = 0
while search('^\s*links to', 'W')
while index < (len(g:res) - 1)
if line('.') > g:res[index].line && line('.') < g:res[index + 1].line
let g:res[index].link = matchlist(getline('.'), '\(\s*links to \)\(.*\)')[2]
break
endif
let index = index + 1
endwhile
if index == len(g:res) - 1
let g:res[index].link = matchlist(getline('.'), '\(\s*links to \)\(.*\)')[2]
endif
endwhile
return g:res
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment