Xcode Auto Complete Code snippet , replace shortcut Text - ios

As you can see, I have added a custom code snippet and a shortcut.
Problem is that my snippet is //ABC and my snippet shortcut is //
Now when i select the snippet from the autocomplete feature in Xcode, it does NOT replace the shortcut text, and it becomes this
`////ABC`
Now in other in build classes/functions in Xcode, autocomplete works in a different way. When we write a wrong spelling and select the autocomplete from Xcode, it replaces the shortcut text. I want to know how to apply this in Custom snippets. I have gone through the edit portion of the snippet but replacing shortcut text is not found. How is this possible? if it is
I am using XCode 8.3, and my OS is macOSSierra.

Related

How to add/remove custom Code snippets in Xcode 11 and above

How to drag and drop a custom code to code snippets and use a shortcut text for auto-fill as we did in Xcode < 10
And how to remove the snippets?
How to add
In Xcode
select line or code to be added in code snippet and then
Option1
Goto Editor
choose the Create code snippet
Option 2
Select Code you want to add to snippet
right click and choose create code snippet
How to Remove
Choose any snippet and press backspace
How to Edit
If you want to edit already added code snippet it is easy. just open code snippet library list (from right corner) from the list select code snippet you want to edit and press SPACE BAR button
Warning : My Xcode crashes randomly couple of time during removing or adding code snippet make sure you save your work (Xcode 10 BUG) :]
Hope it is helpful
Update for Xcode 11
Add code snippet
Same way as before:
Select code
Right click on it
Create Code Snippet
Edit and Delete code snippet
Type cmd + shift + L and you will see the following UI:
For more information about Xcode code snippets check this article.
To add new code snippet in XCODE 10, you can just:- select the codes that you want to create snippet- then right-click on those selected codes - choose Create code snippet.
And to remove the code snippets:
- Just click on the {} icon on the top right nav
- Then select on the code snippet you want to delete
- Press Backspace
If you still want to use Drag & Drop way to create a new code snippet as we did until Xcode 9, you can open Library dialog (shortcut: [Command] + [Option] + [Shift] + [L]) and drag the source code into the dialog.
To edit the snippet
Click on the show panel icon on top right of the Snippet popup
window.
Window will expand to show the code and also the Edit button
Click on panel icon
Edit button now visible

Xcode 9, Selected code snippet type removed when enter key is pressed

In XCode 8.3.3 and below when a code snippet was highlighted and you hit enter, XCode would replace the snippet type with the actual type.
Now when you hit enter it deletes the placeholder type. I've looked around in preferences and cannot find a setting to revert this.
Any help?
Shift + Enter should leave the highlighted text in place
Upgraded to Xcode 10 and it solved the issue

Xcode 7 (7A218 ) search in file behaviour change

Xcode 7 (7A218) changed the default search in file preference.
In case that there are more than one occurrence of the searched text the next item will not move to the beginning of the file. It used to be circular, but now it is just one way.
Is there any way I can alter this to switch back to circular?
Edit Find options -> Mark as Wrap

Xcode wont let me see selected or highlighted syntax.

Lately I have been trying to copy and paste some code around in xcode but for some odd reason, the editor doesnt show what I highlight or select and its really frustrating. The copy and paste works but I can see what I am highlighting. I dont know if this is an xcode settings issue or something else. Please help me. Thanks!
Try these steps:
Goto XCode->Preferences.
Under Font & Colors, See the "Selection" under "your choosen theme".
Adjust the selection color as per your need and you are good to go. The RGB for default selection color is 167, 202, 255 respectively.

Xcode 5 indentation issue

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.
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.
Do anybody see anything wrong in above settings?
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.
Try turning off Auto-Indentation. That way, Xcode doesn't remove formatting.
That was when i customized indentation in Swift and then get back to Obj-C. Nothing with changing preferences helped. Just fully restart xcode.
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.
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.

Resources