pycharmjetbrains-idelinterblack-code-formatter

Is there a way to define keymap shortcuts for external tools depending on the file type, in PyCharm?


One use case would be to have the black code formatter for python files, and the sqlfluff code formatter for SQL files, and to use the same keyboard shortcut for both tools.

Currently, both are set up in Preferences -> Tools -> External Tools, following black documentation.


Solution

  • Sadly no. You cannot assign one shortcut and invoke a different External Tool based on the file extension.

    But you can workaround it pretty easily: