Often when using the quickfix list feature of Vim, I alter or delete a block of text (in my case, generally code) such that the next several items on the quickfix list are invalidated. When I do :cn, Vim realizes that they are deleted, prepending (line deleted) to the original line of code at the bottom of the screen; however, it does not skip them. Is there a way to skip to the next occurence on a line which has not been deleted?

  • I looked in the help in the vicintity of :cn, but did not find anything. – Kazark Feb 7 '13 at 21:02

The error list is static: it doesn't change automatically because Vim doesn't run any background checks or whatever. To get rid of non-existing errors you must regenerate your error list. Plain and simple.

Even IDEs would re-compile your code in such a situation.

  • Yes, but it seems that if Vim has the ability to realize that the line has been deleted, it could have an option to skip to the next one without the need to do any other checks. But +1. – Kazark Feb 7 '13 at 21:43
  • It doesn't have that ability to begin with. The error list is a list of line numbers and file paths, when you delete line 13 there's still a line 13, it's just the former line 14. – romainl Feb 7 '13 at 22:16
  • I'm referring to what I mentioned in my question--when I do :cn, Vim actually says x of y: (line deleted): test... at the bottom of the screen. It recognizes a mismatch in the line it has jumped to and the line in the quickfix item. – Kazark Feb 7 '13 at 22:21
  • :cn jumps to the next error in the error list. Only then it can compare. Comparison can't happen in the background because there's no preprocessor running in the background to update the error list and Vim can't run asynchronous code anyway. If you find a way to seamlessly and asynchronously re-generate the error list then you'll have your feature. But Vim can't do that in its current state. If you feel adventurous you could write a wrapper around :cn that silently catch errors and tries :cn until it can actually jump to an actual error. – romainl Feb 7 '13 at 22:31

If you know what the lines you deleted look like or roughly what the next undeleted line looks like or how much further down it will occur, you can open the quickfix list (:copen) and browse there.

However, this does not explicitly show what lines are deleted, and it is not as quick & easy as a typical Vim command.

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.