Xcode 11 doesn’t paste tabs (thus breaking indentation)

I recently upgraded to Xcode 11 and ran into a very annoying problem: it is breaking my formatting when I copy & paste lines of code (which happen to be in Lua or a DSL).


I had been doing this for years, and what I copied was always pasted intact. I did some searching, and verified that “Re-indent on paste” was unchecked (as was “Indent when typing:” in the Indentation preferences).


I am still on macOS Mojave, if that matters.


Since I do this a lot, it is extremely frustrating. Is there a way to get the old (correct) behavior back?


Note: I just filed FB7422240 since this seems to be a regression with no known workaround.

Doesn't 'Paste and preserve formatting' keep the original formatting ?

Ah, it does keep the indentation (there is no formatting, since Xcode no longer lets you style Lua) but that is not Paste. (I have no muscle memory for a 3-modifier command key. Which if I did, would be for Paste and Match Style which is a different thing.)


This is unformatted text. Tabs are not formatting.

I probably mis your point.


I typed a text in TextEdit

Test with some tabs
     Tab: 1
          Tab: 2
New line


With a single tab on line 2 and double tab on line 3


When I copy into XCode 11.2 beta 2 (11B44), I get the tabs inserted (transformed as 4 space as everywhere in XCode).

I just updated and immediately struck this bug. Super annoying.


Workaround (thanks to Claude31) is to change key bindings so that Paste has no key binding and Paste and Preserve Formatting is bound to Cmd-V.


I notice that XCode 11 has screwed up (some of) my existing custom key bindings as well.

But then you lose the ability to paste into search boxes or help.


Please file a bug report.

Yeah, I just discovered that :-(. I did file a bug report.

Instead of pasting into a new document (which I assume you did), paste them between the braces


{

}


The text will (incorrectly) be indented.

open xcode's settings then text editing tab then select indentation sub-tab and mark re-indent on paste

open xcode's settings then text editing tab then select indentation sub-tab and mark re-indent on paste


No effect

Solution as in XCode 12.2 (yeah, it still happens)
Create a new SwiftUI-file and paste the code from within the { ... } in the new template.
Works.
and this work for me:
Code Block
let pattern_list = #"""
        ^[ ]*[-+*] `?([^::,。?,.?]{1,14}?)`?([::].+$|$)
        """#

Xcode 11 doesn’t paste tabs (thus breaking indentation)
 
 
Q