6

What command could I use to highlight the error in the location list for the line where the cursor is in normal mode? Ie, the inverse operation of selecting a line in the location list and hitting [enter].

2

Also answered here

I just created this for my :Man viewer. It tracks the current item in the 'locationlist' window when navigating:

function! s:visibleLoc()
   return len(filter(getwininfo(), {i,v -> v.loclist}))
endfunc

function! s:followLine()
   let curLine = line(".")
   if (exists("b:lastLine") && b:lastLine == curLine) || 0 == s:visibleLoc()
      return
   endif
   let b:lastLine = line(".")
   let ent = len(filter(getloclist("."), {i,v -> v.lnum <= curLine}))
   if ent < 1 || (exists("b:lastEntry") && b:lastEntry == ent)
      return
   endif
   let b:lastEntry = ent
   let pos = [ 0, curLine, col("."), 0 ]
   exe "ll ".ent
   call setpos(".", pos)
endfunc

au CursorMoved <buffer> call <SID>followLine()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.