How to disable auto-formatting on paste?

Answered
Hello.

I'm using latest pyCharm 2.6.3
If i copy-paste code from one source code file to another, pyCharm seems to apply auto formatting: it indents code, changes closing braces placement etc. Mostly, this automatically applied formatting is wrong, so each time a copy-paste occurs i need to carefully search for formatting that pyCharm messed out and fix it. Is it possible to disable this "auto format on paste" feature completely?
6
25 comments
Settings | Editor | Smart Keys –> Reformat on paste = None
0
Avatar
Permanently deleted user
Unfortunately, it's not working :(. I set "reformat on paste" into "None", opened two empty python files in tabs, entered this code into first file:

before paste
def foo() :
  return [
    "multiline",
    "list",
  ]


Copied it and pasted into second file. The formatting has changed:

after paste
def foo() :
  return [
    "multiline",
    "list",
    ]
0
Installed PyCharm 2.6.3 on Windows 7 in virtual machine (VMware), set reformat to "None" and it works fine for me.

Have no idea why it does not work for you.
0
Avatar
Permanently deleted user
Just tested on clean Windows 8 64-bit in Virtualbox, works as expected :(. And it is not  working on my dev PC. So this must be some settings conflict :(.
0
I'm currently running into this as well since installing 2.7.1.  I haven't tried a fresh reinstall yet.
0
A fresh install of 2.7.3 (including reconfiguration) and this issue is no longer present.  

My hunch says my user config files had some configuration artifacts from (1.x -> 2.x) one of the updates where the config file formatting changed.
0
Avatar
Permanently deleted user

I know this is an old question, but experiencing this same issue on Mac since beginning of the year more or less.

Already tried to reset the property on configuration but had no effect. Anyone has an idea where such settings would be on configuration files to look at them ?

0

On multiple Mac, currently failing. Has been for a while. Hate for platform grows.

When introducing a new feature they are not preserving the existing experience of the new user.  

fail_list += 1

-1

Lost a few hours b/c auto formatting added indent and I missed it.

Beware everyone, PyCharm is a great way to loos serious time over the haphazard feature creep they are releasing.

Seriously need to fix, can't turn it off.

0

Well, here is the synopsis.  It would appear that an update moved what JB calls "simple paste" from CMD+V to some combination guitar style chord key combo.

To disable auto-formatting I killed the default CMD+V (the problem) and assigned that key combo to simple paste.

JB team seemingly changed the default operation of this action and/or changed default functionality.  Both are rookie moves, sorry `brah`, you have some  jumpy as hell dev going on and I should not have to loose so much time for reasons such as paste-operation changing for the worse...

My list of documented fail is long, glad I knocked this one off the list, even if JB platform is broken.

4

Using 2016.2  and there are still some odd quirks with smart paste.

I have 'Reformat on paste' set to none and yet if I paste a few lines below a function define it will move them to the very top of the function.

I also think somehow smart indent is not working properly.

0

I am jumping on this post hard as JB is really doing a crap job and has been giving me unacceptable responses when I report bugs -- and my list is long, very long. 

How do you tell your boss that I just lost 3 hours debugging b/c my IDE paste function is broken? That was yesterday for me.

Again

Marcel, re-assign the key combo to simple paste and it will operate like other programs. 

0

I've considered doing that.  The fact is I really like the ability to cut a section of code and paste it at a different indentation level automatically.  That used to work swell back in early editions (might even have been the beta).

But this thing has caused me enough headache, I might just stop using smart paste for the time being.

1

OMG I totally hear you! It was totally innocuous and then it turned into a serious liability.

I decided that I am going to operate with less "helpers" from the GUI/IDE. Relying on JB or any other team is making us lazy and dangerous.

I have documented a single line paste from a text file pasting 3-5 lines higher than my cursor. That scares the hell out of me!

Also -- a post-Python #comment will frequently remove indentation in a multi-line paste. YIKES!

0

I'm not willing to toss the baby out with the bathwater, so to speak. I like being lazy.  I love the helpers.  I've caught more 'stupid' bugs with pycharm than without.

Case in point; I did a code review of a colleague who didn't use PyCharm and showed them where they had a couple issues.  They were nicely outlined whereas a pure text editor made it very easy to overlook.

I just really really want smart indent paste to work, without having to use reformat on paste.

0

I understand that as well. I left Komodo after almost a decade b/c my team was getting mad at non PEP8 code that ActiveState could not get to lint correctly.

The laziness comment is directed towards creating a negative dependent cycle on a tool that is not stable or realistic. PyCharm, for me, still helps more than it hurts. The overwhelming sloppiness of the IDE as well as the haphazard releases of untested and buggy "enhancements" costs me considerable money.  

I wish JB woudl commit to doing things better and not being spread so thin. The inconsistencies between PyCharm, WebStorm, and PHP storm are really bad.  

0
Avatar
Permanently deleted user

in my mac-version pycharm professional 2017.1,  this solves it:

Settings | Editor | General | Smart Keys –> smart indent pasted lines --> uncheck

2
Avatar
Permanently deleted user

I was suffering from the same problem. non of the mentioned above suggestions worked for me. What worked was I unchecked the "Column Selection Mode" and

the pasting was great from one section to another within the same coding script. Did not have issues when I copied and pasted from one file to another. 

Version: 2017.2.3

Hope this helps.

Thanks

0
Avatar
Permanently deleted user

disable autoformat on paste does not work on my system, ubuntu 16.04, build 2018.3.4, 29 Jan 2019

it messes up the code every time

1

Hi stef,

I believe it is covered by https://youtrack.jetbrains.com/issue/PY-9698 or one of the linked issues.

As a workaround you could try Paste without Formatting action in Settings/Preferences | Keymap.

1
Avatar
Permanently deleted user

Try : 
Settings > Editor > Code Style > Python ( I am using python ) 
Then Select Scheme : Project 

on the same window, you will find multiple tabs where you can set editor behavior based on your preference 

0

It is quite a shame, it still does not work

When I paste Python code, it reformats everything, despite having

Settings | Editor | Smart Keys –> Reformat on paste = None

(Pycharm Professional 2019.3)

2

Try to swap keymaps for: "Paste without formatting" and "Paste". Maybe this will help. 

2

You can try: Editor > General > Smart Keys > Python, uncheck "Smart indent pasted lines"

3

Same problem in WebStorm. Fixed via Editor -> General -> Smart Keys -> Reformat on paste: none.

Note that searching for "reformat" in the settings didn't work for me.

0

Please sign in to leave a comment.