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 n
th 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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With