Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make jetbrains pycharm auto format code on paste

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?

like image 408
Ranjith Ramachandra Avatar asked Dec 05 '13 07:12

Ranjith Ramachandra


People also ask

How do I format a Python script in PyCharm?

The dialog appears when you press Ctrl+Alt+Shift+L in the editor of the current file. If you choose Code | Reformat Code from the main menu or press Ctrl+Alt+L , PyCharm tries to reformat the source code of the specified scope automatically.

How do you paste in PyCharm?

Copy selected text to the Clipboard. Cut to the Clipboard. Paste from the Clipboard. Move (drag) or copy ( Ctrl + drag) a file or directory from the file manager to a directory in the Project tool window.

How do you format a Jetbrain?

Reformat a file Either open your file in the editor and press Ctrl+Alt+Shift+L or in the Project tool window, right-click the file and select Reformat Code.


2 Answers

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.

like image 143
Arnaud P Avatar answered Oct 23 '22 03:10

Arnaud P


Short cut for auto formatting: ctrl + alt + L

like image 35
Zzz... Avatar answered Oct 23 '22 05:10

Zzz...