This function outputs data between braces as joined lines in a quickfix window. The output is sorted based on line numbers.
I'm searching for a method to sort the data alphabetically.
I tried to exclude bufnr
and lnum
, but that breaks the relocation to the actual buffer.
function! Overview() abort
0
let bufnr = bufnr('%')
let items = []
while 1
let start = search('^{', 'cW')
if !start
break
endif
let end = search('^}', 'W')
let lines = getline(start, end)
let lines = map(lines, 'trim(v:val)')
call add(items, {
\ 'bufnr': bufnr,
\ 'lnum': start,
\ 'text': join(lines, ' '),
\ })
endwhile
call setloclist(winnr(), items)
lopen
endfunction
sort()
call after theendwhile
?