I have two code formatters installed: autopep8 and yapf. When I press 'C-c C-r f' (format code) yapf is used. Is there a way to configure elpy to use autopep8 on 'C-c C-r f' (without removing yapf)?
You can achieve what you want by doing the following:
(define-key elpy-refactor-map (kbd "f") 'elpy-autopep8-fix-code)
The default of what is happening is that when you call C-c C-r f, elpy has a switch statement which checks which checker is available. Whatever checker elpy finds first, is the one it ends up using that.
From the looks of it, yapf is the first checker that is checked.
@gopar any equvalent code for yapf, To ensure that Elpy use yapf ?
Found it, sorry I think something wrong with my company-mode. I have to look it manually
(:map elpy-refactor-map
("f" . elpy-yapf-fix-code)))
Most helpful comment
You can achieve what you want by doing the following:
The default of what is happening is that when you call
C-c C-r f, elpy has a switch statement which checks which checker is available. Whatever checker elpy finds first, is the one it ends up using that.From the looks of it,
yapfis the first checker that is checked.