2

I use ALE for finding syntax errors in code in vim, which populates the loclist with any errors found. However, when I first open a file with errors, which populates that list (I have g:ale_lint_on_enter set to 1), no error is highlighted. I like to move between errors using :lnext and :lprevious (in fact I have them bound to keys), but neither will move to the first error! I have to do this with :lfirst. Only then will :lnext and :lprevious move between the errors in this file.

How can I make :lnext and :lprevious do this automatically so I don't have to use :lfirst first to get going?

(To be clear, I don't think this is anything specific to ALE, I think it's anything that populates the loclist. The same behaviour may also occur for the quickfix list, I haven't checked.)

  • 1
    After running :lvimgrep the first match is selected for me (no need for :lfirst). So from my point of view you need this for ALE not the builtin commands which populate the location list . Does :ll highlight the first error in the file? Maybe nmap ]l :ll|ln does the trick. I noticed that ALE provides dedicated <Plug>(ale_next) and <Plug>(ale_previous) maybe they take into account that the first error may not be selected in the file but in the location list. – Hotschke May 25 '19 at 12:46
  • Interesting. So I see the same thing you do with :lvimgrep. So it looks like it may be an ALE issue after all. For now I've mapped like this: nmap ]g <Plug>(ale_next_wrap) (I'm also using vim-unimpaired so ]l conflicts). That seems to work as I expected. Thanks. – Andrew Ferrier May 25 '19 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.