Search code examples
pythonpycharm

Macro to replace print(a) by print(f'{a=}') in Pycharm


In Pycharm, I'd like to create a "macro" that replaces a simple print() by a support = fstring print(), that is, when I have a line of code like that :

print(a)

I would like to replace it by :

print(f"{a=}")

just by pressing a short cut.

It consists in adding f"{ after the ( of the print and =}" before the ) of the print.

I failed to record such a Pycharm macro.

I also guess they are other ways to automate this task. But I have no clue.


Solution

  • I ended up getting there using english keyboard (instead of french keyboard). It looks like :

    enter image description here