Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jump to the errors in the quickfix or location list for the current line in Vim (with Syntastic)

I started using the Syntastic plugin for Vim, which will run a syntax checker on the current buffer and then indicate any lines which have errors. I can open up the list of errors as as a location list using :Errors, and then jump to the line of a given error by hitting Enter, which will jump to the line containing the error in my buffer.

I want to know how I can do the opposite. I want to go from a line in my buffer that is marked with having 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 jump to the nth error in the list, but often I will not know exactly which error number corresponds to the given line in the buffer. I cannot find a command that accepts a line number, rather than an error number, however.

like image 847
gotgenes Avatar asked Feb 08 '13 18:02

gotgenes


People also ask

What is quickfix list in Vim?

The quickfix and location lists provide a powerful way to navigate in Vim especially in the context of searching a file or project, and when inspecting errors. Essentially, they are lists of file locations with a built-in set of commands for navigating between them, and they can be populated in a variety of ways.

How use quickfix window in Vim?

Open Vim in build directory and invoke make from within it using the command :make . This runs Make and fills up the Quickfix buffer with the error output. To open the Quickfix window, use the command :copen . In the screenshot above, the Quickfix window is visible at the bottom.


2 Answers

You're right, there's no built-in way to find out which error is at or after the current cursor position, though that would often be useful. I've written the QuickFixCurrentNumber plugin for that.

With the g<C-q> mapping, you can go to the item in the quickfix / location list for the current cursor position (or the next item after the cursor). It also offers [q / ]q mappings to jump to previous / next errors while limiting the navigation to errors in the current buffer.

like image 125
Ingo Karkat Avatar answered Oct 14 '22 00:10

Ingo Karkat


I think that it's not possible, at least with default Vim commands or Syntastic.

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

like image 42
romainl Avatar answered Oct 14 '22 00:10

romainl