Elpy: How to configure the formatter used on 'C-c C-r f'?

Created on 31 Oct 2018  路  3Comments  路  Source: jorgenschaefer/elpy

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)?

Most helpful comment

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.

All 3 comments

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)))
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yitang picture yitang  路  4Comments

twangnh picture twangnh  路  6Comments

kirk86 picture kirk86  路  5Comments

chechoRP picture chechoRP  路  5Comments

rthompsonj picture rthompsonj  路  6Comments