Find and Replace within a Selection in Xcode 9 - xcode9

I use find and replace in selection all the time. It is crucial to my workflow. It seems to be gone from Xcode 9. This was achieved by holding down the option key once the desired text was selected. The option key would change the context of the replace button to replace in selection. This no longer seems to be available.
Is the ability to find and replace within a selection truly gone from Xcode 9? If not, how do I use it?
Edit: for what it's worth I posted a bug report here.
Edit 2: Here is a timed screen grab with me holding down the option key.
Edit 3: My Xcode version is 9.1 (9B55), someone below with 9.2 doesn't have this problem, maybe it's been fixed in the 9.2 beta.

Apple is aware of this issue. It is fixed in the latest Xcode 9.2 beta. Hold down the Option key; at the right of the replace field, the All button is replaced by All In Selection.
Screen shot of the About dialog, showing the working version:

Related

How do I build an Xcode shortcut for frequently used code snippet? [duplicate]

When I follow all the instructions (including apple's video) to drag text to create a code snippet in xcode, I get a different system behavior: all I see is the selection ibeam... I can't drag. It just ends up selecting text again. Am i missing some obvious Apple-ism?
Thanks
Yes, I ran into the same problem, and Apple-ism seems to be a good term for this issue :)
It works this way:
Select (or highlight) the code your want to turn into a snippet
EDIT: Click and hold (do not drag!) on any part of the selected text for a short moment (like 2 seconds, sometimes 8 seconds)
EDIT: The mouse cursor will change icon (not on El Capitan).
Now you can drag the code over the snippets library, where a green + icon will appear. EDIT: On El Capitan the green icon does not appear, but the frame of the code snippets window will become thinner.
This happened to me as well. The given solution didn't work but still needed to create snippets.
This is a workaround although not the best option, it works.
From Xcode, select the snippet window, and leave it selected.
Open a text editor app.
From Xcode, select and copy the code you want to use to create your snippet.
Paste it into your text editor and then select all of it.
Now drag&drop normally from the text editor into the snippets window in Xcode.
As said, not the best option but it works.
(Note for Xcode 8.1) Sometimes selecting the text and maintain the mouse button clicked for 3..8 seconds the cursor turns into an arrow and it's possible to D&D. Too bad it only works sometimes...
On High Sierra 10.13.3 and XCode 9 I faced the same problem. The decision that works for me is selecting code on a blank space before the first symbol and then dragging it to the snippets library.
Important: you need to drag only from the blank space (look at the screenshot below). Otherwise you will reselect your code again.
The cursor changes only when you start dragging, so don't be confused and don't wait until it changes.
I've run into this problem with Xcode 7.2 on Mac OS X 10.11.2 (El Capitan). Click and hold on the selection and the cursor never changes from the I-beam to the arrow for dragging.
Although MLBDG's answer is a usable workaround, I found that quitting and restarting Xcode fixed the problem. This might not work for everyone, but it's worth a try if you're having difficulty.
just highlight your text
copy in filter text field that u can see on your bottom of snippet library
paste the text
now select the text and drag from there to snippet library
The answer is really !undisobvious. You need to select a chunk of text. Then click on actual text characters, but without moving the mouse. Only then will the gods of XCode bequeath unto you a draggable snippet of code to do with as you please. Should you dare to miss the text and click in empty but selected space, the demons of XCode will strike down your selection and make you start from scratch. The unfortunate will not even realise this feature actually exists.
Hold option to duplicate it. For instance to make a duplicate case statement without destroying your copy buffer, then replace the case you cleverly have ready to paste during your search.
As a UI designer it is not obvious to me why this has such an unreliable twitchy implementation.

How to show the cursor's current line & column position in Xcode?

How do you view the cursor's current line and column position in Xcode? This is irrespective of showing the Line Numbers on the active sheet's left side, how can you show 'Line, Column', or look it up.
Here is an example from Eclipse -
Too my knowledge, showing column number has been removed from new versions of Xcode. You can see line number and set column guide in text editor setting though.
If you are coding in c/c++ I strongly suggest switching to QtCreator or Clion. I personally prefer QtCreator since 1) it has a fakeVim key binding and 2) it is better at loading symbols and giving autocomplete suggestion.
Try this Xcode plugin: Backlight for Xcode
You can use Alcatraz to easily install this plugin, another way of installing it is to:
Download source
Build code
Restart Xcode
(Check Github page on how to further configure the plugin)

XCode 4 Cursor Jumps To First Line When Auto Suggesting

I have a problem in XCode 4.2 when I have the autosuggest feature turned on. Whenever an autosuggest (autocomplete) pops up, the cursor will jump to the top of the file, to the second character of the first line. This happens regardless of whether or not I select the autosuggest or take any other action. As soon as I turn off the autosuggest feature, this behavior stops happening.
I have turned off all key binding associated with jumping to the top of the page and have deleted all derived data for the project as per some suggestions I have heard, but have not been able to solve the problem.
Anybody have a solution?
I had similar problem Xcode cursor jumped randomly. It was triggered by an editor theme using an italic font. I changed the font to a regular one, and the problem was resolved.
Simple solution (or workaround):
Open Preferences.
Open Fonts & Colors tab.
Select Basic theme.
I got the hint from this page.
Just in case there is a bounty awarded :) let me repeat my "solution" from above: I suggest moving aside your /Developer folder and re-installing Xcode. Simply running the installer w/o removing the old /Developer folder may not replace all the necessary files. Good luck.
I have had a similar problem where the cursor jumped to the top and I couldn't scroll down. I don't know if it is the same problem that you have but there is no real solution. Its just one of Xcode's bugs there are a lot more. Open another file in the project and go back to the file you were working on, close and reopen the project or restart Xcode. Thats the only solutions I found.
If thats not working, then you can always re-install Xcode

How do I know what COLUMN my cursor is at in Xcode?

Sometimes I want to know what column my cursor is at, so I can see how many characters I have left til the print margin.
This is a common functionality in most IDEs and text editors, but I couldn't find it in Xcode.
Is it possible to enable this or see it somewhere?
Open Xcode's Preferences, go to the Text Editing tab, Editing subtab, and check the "Page guide at column: 80" box. That will display a vertical line at 80 columns in the editor.
EDIT Oct 6, 2021:
Holy moly. Xcode 13 now shows both the line and column number in the IDE! It took ten years but Apple listened.
Original Post:
If you find this post, please log in to the Apple Bug Reporter site and report this as a bug against the Xcode developer tool. Mention that Xcode needs to provide an option to display the cursor column position and that the page guide is insufficient. Apple should mark it as a duplicate request of bug #8315595.
The more requests they get the greater the likelihood they'll repair it and this is a very useful feature for many developers.
Turns out as for now (Xcode 4.3.2), it can't be done.
My solution was eventually moving to AppCode :)

Behavior and Preference Differences in Xcode 4 vs Xcode 3

I just upgraded to Xcode 4 (from 3.2.4) and while there are a lot of behavior/preference changes I need to get used to, I'd like to get a couple issues handled sooner rather than later.
Can I exclude the delimiters when balancing delimiters? In v3.x, you could balance delimiters and the selection would exclude the enclosing braces. Is that possible with v4?
Is there an equivalent to the advanced find/search available in v3? Used to ctrl-click on a symbol and select search in project which opened a new search window. You could also define different search sets to use when searching. I can't find any similar behavior in v4.
Finally, does anyone know if the Apple developer forums are available to users who have only registered as a developer (but not joined)?
Thanks!
Under the Help menu in Xcode 4 there is an option for Xcode User Guide which covers what you can do with Xcode 4. I have been through it and it seems pretty light so far so it may not have what you need, but it is a good place to start.
I also did a search in Help and quickly found that you can change this setting with a checkbox in Preferences under Text Editing. I've included a screenshot with the option highlighted below.

Resources