15

enter image description here

I use eslint with ale to lint my Javascript code. After editing a code block, I often have a few errors to fix. Fixing is done by navigating to the next erroneous line, reading the problem from the ruler and fixing.

If I could skip the navigation phase and use a specific key binding to navigate to the location of the next error - its line, and hopefully its column - it would be great.

Is there a way to use key binding to navigate to the next lint/ale error?

18

ALE has many commands that can navigate linting errors, and :ALENext works great for this operation. By default, ALE maps no bindings, I assume to allow for non-clashing customization.

In your ~/.vimrc (or ~/.config/nvim/init.vim for NeoVim), I use:

nmap <silent> <leader>aj :ALENext<cr>
nmap <silent> <leader>ak :ALEPrevious<cr>

Leader is \ by default

  • Maybe worth adding that if you want to jump specifically to errors or warnings, that (verbatim from the docs): "-error, -warning and -info enable jumping to errors, warnings or infos respectively, ignoring anything else. They are mutually exclusive and if several are provided the priority is the following: error > warning > info." – Harry Mar 25 at 17:44
10

You can easily move between errors by adding some Plug key bindings.

In this example use Ctrl+j to go to next error and Ctrl+k to go to the previous error.

nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
  • 1
    This assumes that you have Plug rather than Vundle or Pathogen installed. – icc97 Nov 25 '18 at 16:36
  • This appears to come direct from the ALE repo README: github.com/w0rp/… – icc97 Nov 25 '18 at 19:55

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.