Paste without auto-formatting


I'm working with some complicated code that is indented the way the previous developer liked it, which is adequate to work with, but if I copy and paste a section, it auto-formats it completely changing the indentation and line breaks, making it hard to compare sections for new changes.

How do I stop this? I want a literal exact copy-and-paste and only auto-formatting if I manually do it through my hotkeys.


Settings/Preferences | Editor | General | Smart Keys --> Reformat on Paste

Also/Alternative: "Edit | Paste Simple" -- should just paste without any additional auto-actions/improvements on top


As Andriy mentioned, 'Paste simple', whose hotkey is 'Ctrl+Alt+Shift+V', will preserve the literal whitespace and formatting of the pasted text. That's what I use in these cases.


I want to turn it on. Can't find "Settings/Preferences | Editor | General | Smart Keys --> Reformat on Paste"


@David Yost

Try search field -- it helps narrowing the stuff a lot:


"Help | Find Action..." (Ctrl+Shift+A on Windows using Default keymap) also allows to locate that option even from Welcome screen:


"Paste Simple" is not available in pycharm 2022.1.1 professional edition.

Also my reformat on paste is set to None.

Still the formatting seems to change, especially the indentation. Single line code are put in multiple lines.


In addition to Settings | Editor | General | Smart Keys | "Reformat on Paste", you need to uncheck Settings | Editor | General | Smart Keys | Python → "Smart indent pasted lines"


Thanks to Stian Kristoffer Endresen addition. Alternatively, if you still want to keep smart indent, but not to break lines, you can set "Hard Wrap at" to 999. See the screenshot here:


Please sign in to leave a comment.