Created
May 31, 2017 22:57
-
-
Save tjdevries/8c1901061ae87d3466e3631a1c2bf152 to your computer and use it in GitHub Desktop.
searching syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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