0

I often get an eslint error in a Javascript file, which is trivial to fix - for example, trailing spaces or incorrect indentation:

enter image description here

In this case, I would have to ^XX to navigate to the beginning of the line and delete two spaces. Not the end of the world, but some cases - like long lines that needs to be broken - are more cumbersome. Note that I am not looking for a complete auto-fix for the file, just a quick fix apply for the current highlighted problem.

Is there a way to define a key binding that would auto-fix the current eslint error, if possible?

  • you should check your tabstop, shiftwidth, softtabstop and perhaps shiftround option – Christian Brabandt Jul 18 '17 at 8:28
  • Will do! That would probably help me avoid this specific problem, but would it help me with auto-fixing with eslint? – Adam Matan Jul 18 '17 at 8:31
  • for the given example, a simple << should work, if your cursor is on the correct line – Christian Brabandt Jul 18 '17 at 8:34
  • @ChristianBrabandt True, but there are other, more complicated errors, and I'm looking for a more general auto-fix solution for the current error. – Adam Matan Jul 18 '17 at 8:36
  • i am not sure, there exists such a general auto-fixable solution. My guess is, you need a custom-tailored solution for your specific requirements, that could be a function called after your linter is finished and tries to fix some easy problems or does some kind of pretty-printing before running the syntax checker. – Christian Brabandt Jul 18 '17 at 8:41

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.