I have 3 general questions related to the usage of xCode. Any help would be greatly appreciated please:
Whenever I open documentation, the left content/index column is always small and I have to drag it wider. Is there a way to permanently set its size?
Is there a way to perform a wildcard search and replace e.g. I have 3 lines:
var1Letter = #"A";
var2Letter = #"A";
var3Letter = #"A";
In the above I would like to replace var?letter in 1 go.
How do I set the default SDK?
Thanks.
re #2: Xcode can use regular expressions. You need to select the regular expression type though (it usually says textual) and that will let you do a search and replace. Xcode uses the ICU regex syntax.
To do the wildcard search, use regular expressions and use \n in the replacement text.
I'm using Xcode 3.2, but I think that older versions use the same regular expression syntax. Use the Find… (cmd-F) command. Choose "Find & Replace" from the pop-up menu. Choose "Regular Expression" mode from the pop-up menu in the search text field. Enter "var(\d+)Letter" for the search text, and "var\1letter" for the replacement text.
The "\d+" syntax matches any sequence of one or more digits. The "\1" is replaced by the text matched by the first set of parentheses in the search text.
Here's all I know:
Not sure; I have seen this problem, too, and don't know of a workaround.
As far as I know XCode doesn't handle regular-expression-based search/replace, which is what you'd need for this situation.
The setting you're looking for is "Base SDK", which can be configured both per-project and per-target (which overrides the project setting) by right-clicking on the project icon or the target icon, respectively, and choosing "Get Info" from the context menu. The Base SDK setting is one of the first under the Build tab.
For #3, There's no way to set new default SDK for all new projects that you create. The easiest way that I've found is to create an .xcconfig file that gets imported to every new project that I make.
An alternative to this would be to edit the default Xcode project (The base template for a base application is found at Developer/Library/Xcode/Project Templates/Application/Cocoa Application/Cocoa Application/__PROJECTNAME__.xcodeprjo/project.pbxproj) and change the SDKROOT value.
Related
I'm running into an issue where XCode 7.3 autocomplete searches all possible constants using some kind of weird pattern matching algorithm. The result is that I practically have to spell the entire constant name before autocomplete allows me to press "enter" to select the suggestion.
How can I force XCode to do old, strict "begins with" autocomplete search algorithm?
For example, attempting to search for constant kEditTag, I would expect it to show up once I type kEd..., while currently I have to type keditta, to have the suggestion even show up in the autocomplete list, making it rather useless:
Please go to XCode -> Preferences -> Text Editing and "Enable type-over completions" . This should do the trick
When start to type write 2 or 3 character so xcode can interprete what you want in completion. use ctrl + space
I'm using Xcode 5, and want to find a word (ex:variable name) not by substring match but by exact match (or prefix match). In file wide search (Command-F), I can use Textual search or regular expression search by clicking the arrow button just right of the glass icon and choosing "Edit Find Options...".
But, I cannot find any option to search on project wide search ("Find in Project", Shift-Command-F), in Xcode 5.
One thing I can do is run "grep -w" on Terminal.app. But, isn't there any way to search word in Project inside Xcode?
Well it seems that the search tool in Xcode 5 is a bit confusing for a lot of people. In my opinion Apple should have done a better work letting the user know of what is clickable and what not... That being said, here is how you access the different options:
Once we switch to the Find Navigator we see 3 components (Find>Text>Containing)
Now, you can click on any of them to select between different options (à la jumpbar)
And finally you can also click the In Workspace (or In Project) to change the scope of your search
In Xcode 6 the problem I was having was that my Framework folder wasn't being searched, even though it was clearly part of the project (but in /Library/Frameworks), and even when I had one of its files open with the string showing in the editor.
Changing the scope from In Project to My Scope (as shown) even allowed me to find the search string in non-frameworks folders.
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".
Can it be done? We're using VS2005, VS2008, and VS2010.
I don't mean regular expressions—which have their place—but plain old text find and replace. I know we can do it (at a pinch) with regular expressions using the \n tag, but we prefer not to get tangled up in regex escape characters, plus there's a readability issue.
If it can't be done, what plain and simple (free) alternative are people using? That doesn't involve knocking up our own macro.
I finally found it...
There isn't any need to download and load any external macro.
It’s working in Visual Studio 2008 with in-built macro at least. :)
Steps:
Select text you want to find.
Press Alt + F8 or open "Tools -> Macros -> Macro Explorer"
Double click Sample → Utilities → FindLine. (It will open the Find box with your selection loaded in the "Find" field. Don't worry about truncated text shown in the "Find" field. Trust me, the field has it all... The Microsoft way of showing it may be... :) )
Click on the "Quick Replace" button in the "Find And Replace" dialog box. Enter your replace with text.
And click any of three buttons as per your requirement...and it’s done. :)
Hurray... it’s working. It may not be a straightforward way to do it, but you know with Microsoft. Nothing is straightforward and easy.. :)
This works today in Visual Studio 2012:
fooPatternToStart.*(.*\n)+?.*barPatternToEnd
See how the (.*\n)+? part does the match across multiple lines, non-greedy.
fooPatternToStart is some regex pattern on your start line, while barPatternToEnd is your pattern to find on another line below, possibly many lines below...
Example found here.
Simple and effective :)
Note: before VS2012, the pattern that worked was: fooPatternToStart.(.\n)+#.*barPatternToEnd
You can search for multiline expressions by clicking on the "Use Regular Expressions" checkbox in the "Find and Replace" dialog. Line breaks are then indicated by \n.
I use this:
Visual Studio Gallery Multiline Search and Replace
It’s provided by Microsoft only. Please check Multiline Search and Replace.
It uses regular expression only. But for those who don't know regex, it is better to use it.
You could also open the files with UltraEdit which fully supports MultiLine replace.
You can use the trial version if you only intend to use it once.
Regarding the comment of Andrew Corkery:
If you like to specify a multi-line replacement string as well, edit the macro code and set the replacement text as shown below.
This will allow you to "fine-tune" your replacement with just the small modifications needed.
Sub FindLine()
Dim textSelection As TextSelection
textSelection = DTE.ActiveDocument.Selection
textSelection.CharLeft(True)
DTE.ExecuteCommand("Edit.Find")
DTE.Find.FindWhat = textSelection.Text
' Also preset replacement text with current selection
DTE.Find.ReplaceWith = textSelection.Text
End Sub
The latest version (as of this posting) of Notepad++ does multi-line find/replace. With no macro support in Visual Studio any more, this is relevant now.
Noob xcoder here and for some reason i cannot get the text macros to expand within xcode. For example if i type ifelse and then hit ^. it doesnt automatically expand the macro?? Likewise if i type fo and then ^. it will complete it to either for,fori etc, and will also pop up those options if i hit escape however i cannot get it to expand the macros unless i am misunderstanding how this works?
Make sure the shortcut for menu item Edit->Next Completion is indeed ^. If it is not, go to Xcode preferences, Key Bindings and edit it.
Try rebuilding your code sense index from the Project Info panel.