I get indentation issues when I copy few lines and paste it. Xcode does not copy indentation properly or applies another indentations.
As shown in below images, I copied first function and pasted which is second function. Indentation are reapplied except for first line.
enter image description here
I played with Xcode indentation settings but could not solve it neither do I have any clue why this happens.
Below are 2 indentation settings I tried.
enter image description here
enter image description here
Do anybody see anything wrong in above settings?
-
do you simply paste with command-V (plain ol' paste) or do you use the paste-and-preserve-formatting Xcode edit menu choice (which has a crazy key combination including command-V)??Michael Dautermann– Michael Dautermann2013年11月29日 05:44:59 +00:00Commented Nov 29, 2013 at 5:44
-
@MichaelDautermann I use command-V.Geek– Geek2013年11月29日 05:59:14 +00:00Commented Nov 29, 2013 at 5:59
5 Answers 5
In Xcode preferences, Key Bindings tab, redefine ⌘-V to "Paste and Preserve Formatting" and ⌘-option-shift-V to "Paste". Then ⌘-V will do "Paste and Preserve Formatting" which is what you want.
Comments
Try turning off Auto-Indentation. That way, Xcode doesn't remove formatting.
Comments
That was when i customized indentation in Swift and then get back to Obj-C. Nothing with changing preferences helped. Just fully restart xcode.
Comments
With cut and paste, you have to actually tell xcode to indent after the pasting.
⌘ A and then Control I. The first one select the whole class contents (when the cursor is inside) and the second one indents it based on your indent preferences.
Hope this helps.
6 Comments
I just checked Xcode settings in another mac and made changes to match that and solved the issue. Sorry I don't remember what were they as it has been too long.