How to make jetbrains pycharm auto format code on paste
12,973
Solution 1
Edit to keep up to date:
The option Settings | Editor | General | Smart Keys | Smart indent pasted lines
will be of interest (Pycharm 2016.3).
Things are always evolving, as a general (and faster) practice, I would recommend to start typing smart indent
as soon as the settings window appear. Menus will narrow down to help find where the option sits.
Or even more fancy, Ctrl + Shift + A
directly from the editor (search everywhere) can bring you to it.
Solution 2
Short cut for auto formatting: ctrl + alt + L
Related videos on Youtube
Author by
Ranjith Ramachandra
Updated on July 12, 2022Comments
-
Ranjith Ramachandra almost 2 years
When I used webstorm and I pasted a bit of code from somewhere else it would do the formatting for me. But with pycharm 3, it is not happening anymore and I have to manually indent the code etc.
I want to get that feature back. Is there a way to do that?
-
LazyOne over 10 years1) Select your code fragment and
Code | Reformat Code...
orCode | Auto-Indent Lines
? 2) Check what you have atSettings | Editor | Smart Keys | Reformat on paste
P.S. These are just general suggestions, since I'm not a PyCharm user.
-
-
carrabino over 10 yearsthank you very much. Just so others know, there are 4 additional sub-options, "None" will leave the formatting in tact as you paste.
-
John C almost 8 yearsPyCharm 5 has it under
Settings | Editor | General | Smart Keys | Reformat on Paste
, fyi.