1

I know about the practical differences (e.g., one Vim session can have only one quickfix window but multiple location list windows, etc.), but what are the essential differences? When should I prefer one over the other? What do their names signify?

I personally use only quickfix windows. Mostly because it requires one less key (:lgrep vs :grep). But I recently saw this message from Christian Brabandt:

I tend to use the locationlist, because it is more flexible and you can have more than one.

The question that this message gave rise to is: if one is more flexible, or better, than the other, then why do we have them both? Surely having similar features implemented twice only increases the surface area for bugs without adding much value to the user, right?

1 Answer 1

1

The quickfix list and the location list are actually the same feature, implemented in src/quickfix.c. The location list is more of a special case than anything.

The way I see it, the two lists have a relationship similar to the one between buffers and windows, with the former being the basic, historical version and the latter being an extension of the former, adding more flexibility to the mix.

The initial use case for the quickfix list was doing make at the root of a project and having a mechanism for handling eventual compilation errors in the editor, and it does that very well. From there, the feature grew to cover other scenarios (searching, linting, etc.) for which the "one-to-many" aspect of the original quickfix list might not always be ideal.

Consider linting on write. The output of the linter will only ever have errors in the current file so, if you have several windows, then scoping the quickfix list to the current window starts to make sense. Hence the location list.

The two lists (and windows) kind of overlap if you only have one window, which might be a little bit confusing, but the differences and pros/cons are more obvious in a multi-window setup. In a "one-to-many" scenario (one command leads to many files: search in whole project, build project, run whole test suite, etc.), the quickfix list seems more appropriate to me. In a "one-to-one" scenario (one command leads to current file: lint current file, search current file, etc.), the location list seems more appropriate to me.

1
  • I would have waited for additional input.
    – romainl
    Jun 26, 2023 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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