Go to quickfix or location list errors for current line in Vim (using Syntastic)

I started using the Syntastic plugin for Vim, which will run parsing in the current buffer, and then specify any lines that have errors. I can open the error list as a location list with :Errors , and then go to the line of the error by pressing Enter , which will go to the line containing the error in my buffer.

I want to know how I can do the opposite. I want to jump from a line in my buffer marked with a syntax error to the corresponding entry in the location list so that I can read the full error message in the list. How can i do this? I know that :ll [n] will go to n th error in the list, but often I don’t know exactly what error number corresponds to this line in the buffer. However, I cannot find a command that accepts a line number, not an error number.

+7
source share
4 answers

I think this is not possible, at least with the default Vim or Syntastic commands.

But Syntastic actually echoes the error message associated with the current line on your command line. This feature is enabled by default.

+3
source

You are right, there is no built-in way to find out which error is on or after the current cursor position, although this would often be useful. I wrote a QuickFixCurrentNumber plugin for this.

When g<Cq> displayed, you can go to the item in the quick fix / location list for the current cursor position (or the next item after the cursor). It also offers [q / ]q mappings to go to previous / next errors, limiting navigation to errors in the current buffer.

+8
source

I just created this for my: Man. 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() 
+2
source

I tried to enable this feature here, which led to:

Vim-loclist-follow:
https://www.vim.org/scripts/script.php?script_id=5799
https://github.com/elbeardmorez/vim-loclist-follow

Nothing special, it just ensures that the β€œnearest” item is selected. Works for me (β„’ using) using any of my Syntastic installations, or now Ale.

0
source

All Articles