Reputation: 35364
I want to turn off code auto-formation in PyCharm
I often get my comments auto-formatted
from
#my comment
to
# my comment with space inserted
I want to turn this off and found via google this article from JetBrains; though I cannot find the guided option in my PyCharm as snapshots below.
I'm using
PyCharm 2016.2.3
Build #PY-162.1967.10, built on September 7, 2016
Upvotes: 19
Views: 12775
Reputation: 11
In addtion to "Reformat on paste" setting to NONE (Editor || General || Smart Keys), you have to also set "Smart ident pasted lines" under Editor || General || Smart Keys || Python
Upvotes: 1
Reputation: 80192
[File > Settings > Keymap]
, search for Paste
, right click on "Paste as Plain Text", and reassign the key Ctrl-C
to it.
Tested with PyCharm 2021.3.2, should work in the latest.
Upvotes: 6
Reputation: 324
For me, I was trying to paste a line of regular non-code text and then use the comment shortcut to comment out the pasted text. PyCharm auto-formats the text to be one line for each word. (It breaks on any white space.) I also only have this problem when I paste on an indented line
The workaround is to always type #
and then paste. Or Edit - Paste - Paste as Plain Text. I still consider it a bug.
Upvotes: 1
Reputation: 11
Just go to File>Setting>Save Actions and turn off all actions. Hit apply and you are good to go.See the picture for more info.
Upvotes: 0
Reputation: 1181
look under Preferences -> Editor -> General -> Smart Keys -> Reformat On Paste and set to 'None'. see screen.
UPDATE: looks like the suggestion above didn't work, but i did find another editor setting (python-specific) that will auto-format your code. see attached screenshot. you can get to the setting via:
Preferences->Editor->Code Style->Python
near the bottom. deselect the after #
setting and try again. this worked for me -- it allowed me to paste the string you had above without having it auto-formatted. HTH
Upvotes: 14