Xcode's Change Case of Letter shortcut doesn't seem to work - xcode

In Preferences->Key Bindings->Text Key Bindings Xcode has a "Change Case of Letter" key binding. However, when I assign a shortcut to this binding and then attempt to utilize it to swap the case of a letter in one of my source code files, it doesn't seem to do anything.
I've tried positioning the cursor before and after the letter, and tried selecting the letter before triggering the assigned shortcut. Nothing seems to do anything.
Does anybody know what I might be doing wrong?

That had been a general AppKit text function, but was apparently removed several years ago. I'll update Xcode's text bindings to reflect it.
Instead, write a user script:
(source: mac.com)
and assign it whatever shortcut you want.

Related

Mac OS option key shortcuts not working, how to make it work?

I have a very long line which I want to view as wrapped.
There is an option called word wrap that can help me achieve this.
Anyhow the shortcut method option + z doesn't work, instead inserts a ˀ there.
Any solutions?
Looks like one of your extension might be overriding your VSCode config. Try ⌘+SHIFT+P/CMD+SHIFT+P and then search for View: Toggle Word Wrap/Toggle Word Wrap.
You will then be able to see the shortcut assigned to that command on your local PC. Alternatively, ⌘+SHIFT+P/CMD+SHIFT+P and search for Keyboard Shortcuts. In there search for OPTION+z and check for the answers which pop up.

How to delete whitespace backward in Xcode

I would like to use Xcode editor instead of others for swift typing but I am missing basic functionality of deleting whitespace backward.
Normally in the world of code editors, you just press option + backspace or something similar and thats it, it deletes whitespace just until next character starts, eating new line in the way as everyone needs.
But xCode is doing some wired unusable staff and is deleting not just whitespace and new line, but also part of text on previous line, until it considers some character start of word, basically making it unusable.
I don't need to know how to use "Delete subword backward" !
All key bindings can be edited in Xcode -> Preferences -> Key Bindings.
By default the combination you're interested in is assigned to something like Delete Subword Forward. Just remove the combination from the action that you don't need and add it to the action called Delete Forward (or whatever action you're looking for, it's not very clear).
To add a key binding you double click on existing Key value, click +, press Option+Backspace, click somewhere outside the field to save new value.

Xcode 8 and 9: how to disable code completion when clicking "Tab"

I often use Xcode snippets which contain fields to fill (like <#time_interval#>), I jump between those fields with tabulator. Sometimes, when I fill a field with a word and click tab to jump to next field, Xcode automatically changes word to first suggestion from autocompletion dropdown, e.g. HelloWorld. I don't want to disable suggestions, I just want to disable completing my code on clicking tab. Is there a way to do so? I feel extremely dumb because I make iOS apps for over 7 years already and this setting drives me crazy. It should be something simple somewhere and I must have missed it over and over.
UPDATE for clarification (images):
Click tab and enter one field to fill it:
Type what you want to have there e.g. "literal" word:
Click tab again to pass onto next fillMe field. Expected result:
Actual result (instead of word "literal" you get Color Literal there which is the first position in autocompletion list):
You may use CMD+Z as a workaround - it will revert Xcode autocompletion and leave everything else as is.

How can I find and replace inside a selection in Xcode?

In Xcode < 4, you could hold the "option" key, and the "Replace All" button would change to "Replace in Selection". As of Xcode 4, this does nothing. Anyone know if there's a new way to do it, or is it bug filing time?
This appears to be working again now, at least in Xcode 4.4.1.
When the find/replace bar appears at the top of the editor, holding down the option key on the keyboard causes "Replace in Selection" to appear in lieu of "Replace All."
I'm glad, because this was an ANNOYING omission.
Another workaround:
In Xcode, select the text, press copy
In a terminal session:
pbpaste|sed 's/SOURCETEXT/NEWTEXT/g'|pbcopy
Return to Xcode window, press paste
Since the original should still be selected, it will just be replaced. You could probably build a simple shell script to do this.
Doug
An few images to supplement the chosen answer:
And holding down Option:
See also
Find/Replace in Xcode using Regular Expressions
Seems like missing functionality. You should file a bug report.
I'm upset that they took out this functionality, as I used it constantly, but here's my workaround. Copy your selected text from Xcode4 to TextEdit or some other word processor, do the find and replace there, and then copy the results back into Xcode.
It's not sexy but it's worth it if you do a lot of these "find and replace on my selection", and you leave the word processor open in Spaces as you work.
They should add "my selection" as an alternative to "workspace" and "my scope".
There is another way only replace the matches you find, rather than just this one or all of them.
I suggest you save a copy first, just in case....
In Find and Replace, Show Find Options (you can do this by pressing the magnifying glass).
Press Preview.
Uncheck all the ones you don't want replacing.
Press Replace
Hope that helps, it did me.
Not ideal, but not too bad:
Do a find and replace in workspace (cmd-opt-shift-f) enter your desired find/replace
Enter your desired search term and hit return
Select the range of replacements from the list of matches on the left
Hit replace (not replace all)
To replace text in a selection using Xcode 9
Press Option-Command-F to bring up the find/replace box.
Enter the search and replace string. Changing the search string will lose any existing selection, so..
Make your selection (again). (If you don't do this, the selection will be the first search string found only)
Hold down the key and "Replace All" will change to "Replace Selection", then click it.
Once you understand that you make your selection AFTER you have entered the search string, then this is not that clumbersome and works fine.
I find alt-command-f easier for local find and replace (4.3) and then working around your selection.
EthenA.Wilson asked in a comment to the OP a couple of days ago:
"Is there a way to do this in Xcode 5?"
For the benefit of those who, like me, had been searching for it, here's how:
After you put your Find and Replace terms in the bars at the top left-hand side of the editor page, select the text you want to search in, then look at the top right-hand side (same bar). You'll see where it says "All", right next to "Replace." Now press the Option key. "All" will change to "All in Selection." Click it, and you're done. Could be a bit more intuitive, but the functionality is there in Xcode 5.
Naturally, good idea to take a snapshot before you click!
HTH!
Not sure which feature prior to Xcode 4 you're referring to, but the shortcut Command+Shift+E gives you "Use Selection for Replace". If you're talking about "Find and Replace in Workspace" (Command+Option+Shift+F), then what you need to do is run your find and then hold down "Shift" or "Command" on the selections shown and then hit "Replace".

How to make Xcode auto-complete act like bash auto-completes file names

If I type UITa, then it might show an autocompletion of UITableViewDataSource. So I press enter and that's what I get. But what I wanted was UITableViewDelegate. If this was when we input the file name in the command line of bash, then it would have auto-completed up to UITableViewD, and then I would have to enter a to get an autocompletion for UITableViewDataSource, or e to get UITableViewDelegate.
Is there a way to make Xcode work like that, or another way to avoid this problem?
In my machine (XCode 3.2.3 on OS X 10.6.4) the auto-completion works exactly as you described you want to behave.
Typing
NSMut
shows something like
NSMutableArray
Note that NSMut, able, and Array are all displayed in a different color/font in XCode.
Typing D here to change the completion to NSMutableDictionary does not work, but hitting Enter or the right arrow key changes the selection up to
NSMutableArray
Hitting D here changes the completion to
NSMutableDictionary
If you want the possible list of auto-completions, just hit the escape key. Hitting escape key is the general way to get the list of completion in any Cocoa app on OS X. In any Cocoa text box you'll get the list of English words which matches the first few letters you typed.
Xcode autocompletion can be inconsistent. Workaround: After typing some characters, hit ESC and Xcode will pop up a scrollable list of completion options. Continue typing to narrow down the list. Use the up/down arrow keys to navigate the list. Hit return to complete using the selected text. This approach can be helpful when Xcode autocompletion is acting flaky.

Resources