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.
Related
I have been developing in zend studio and there is a feature I miss a lot in Xcode. When you are reading code in a main function and you want to go in a specific function to read something, you can click in the left area of your current line of code were your are, and a flag-mark appears in that line of code, so you can go anywere else in the code and it will be very easy to come back to that line of code you were before because there is a flag and you only have to click on it and you automatically go back. Does Anybody know a similar way to do this in Xcode?
Unfortunately, this feature was present in earlier versions of Xcode (up to Xcode3 IIRC) and was called "Bookmarks", but it was removed since then.
You can use breakpoints (and disable them) as a workaround, even if it's not perfect. I personally prefer using other tricks, like "Open Quickly" and named tabs.
Alternate trick 1 : "Open Quickly"
One trick is to use Command+Shift+O (or "File" menu > "Open Quickly") to quickly open a file. In the field that appears, you can type:
The name or parts of the name of a file.
Typing "MainViewController" will propose to jump to the MainViewController.h or MainViewController.m file.
Typing "MainVC" will work too, as well as "MainViewCtrl", as long as the order of the letters you type is the same as the full name.
Very handy to just type "ContTVCell" to open the ContactsTableViewCell.h file that is hidden deep in subgroups of my project for example
Similarly, you may also type the name or parts of the name of a symbol, especially a method name.
For example, typing tvcellforrow will list you all the definitions of -tableView:cellForRowAtIndexPath: it could find in your project and let to jump to the one you want
When typing (parts of) the name of a file, adding : followed by a number at the end will allow you to directly jump at the corresponding line
For example, typing mvc:50 will propose you to jump to line 50 of MainViewController.h or MainViewController.m
Another trick : using (named) tabs
Don't forget that you can open tabs in Xcode, which can be very handy in this kind of situation.
When you are editing a file at some interesting position, you can create a new tab to browse elsewhere and go at any other place… and then go back to your first tab to find the code where you left it at the time you switched to the other tab.
Don't forget that you can name your tabs (simply double-click on their title) to give them a more explicit title. You may then quite think of them as "named bookmarks" somehow
Likewise, don't forget that you can detach tabs in separate windows too, if you prefer (for example to keep them around and visible on your secondary screen while you edit another part of your code)
You can even combine this with the "Open Quickly" trick presented above: once you made the "Open Quickly" field appear and typed something into it, instead of just validating using the enter key:
use Alt+Shift+enter to let Xcode present you a small widget that let you choose where you want the file to open (in the current tab, in another tab, in the assistant editor, in a dedicated window…)
use Alt+enter to open the file using the alternate navigation defined in Xcode preferences (Xcode > Preferences > Navigation > Optional Navigation). By default, the behavior when opening a file while using the Alt key is to open the file in the Assistant Editor. Personally I changed that in my Xcode preferences as I prefer to make Xcode open the file in a separate tab instead, which makes Alt+clic much more useful.
Sure, all those tricks with "Open Quickly…" and "Tabs" do not replace the bookmarks feature that you are missing. But they are still nice alternate ways to jump quickly to any position in your code, even any specific line of any specific file in your project, wherever you are in Xcode (even without having to have the Project Navigator visible on the left part of your window), and let you have multiple editors in different tabs to go quickly back to a part of interest in your code
its on top of your editor i have added two pics just check them.
When you navigate to another place in Xcode, say, open a different file, or Command-click and jump to definition, you can go forward and back by swiping right or left on the trackpad with two fingers.
You can also use keyboard shortcuts: Ctrl+⌘+→ to go forward, or Ctrl+⌘+← to go back.
Finally, you can click triangular buttons at the top left in your edit area.
There is a go back button at the top left of the editor!
If that is not good enough, whar I do is misuse breakpoints to set flags in my code. The breakpoint navigator thus becomes a table of flags. It isn't much but there you are.
I'm a NotePad++ user, new to TextMate.
There are some features that I really like in NP++ but couldn't figure out if TextMate support them.
Double click on a variable and have all instances highlighted
View 2 text windows side by side
Drag a file onto another opened Window
For this one, I don't know how to generate a screenshot ;-p. Basically, you can drag a file from Windows Explorer and drop it into NP++ to have it opened.
A lot of long time TextMate users are leaving TextMate land, actually. So, I'm not sure it's the right time to move to TextMate.
Emacs and Vim both do what you want and more. If you can afford the learning curve it's definitely worth it.
As for your question:
View 2 text windows side by side
You can have two or more windows for the same document. Assuming you are in a "project" right-click your file in the drawer and choose Open "foo.ext" in New Window. The two "views" contents are more or less in sync but doing cool things like columnar editing tends to break the syncing.
Due to how Mac OS X manages windows, the new window will probably be too large/too small and/or placed in a less than useful place. I use ShiftIt system wide to manage my windows and in such a case have them the same size side by side.
Double click on a variable and have all instances highlighted
What do you use this for? Is this visual highlight or non-contiguous selection?
Type ctrlw to select the word, then ⌘e to make the word your search term, then ⇧⌘f or Edit > Find > Find in Project… It will show all instances of the search term in another window. You can then "jump" to any occurence and do whatever you want.
If you only want to jump from occurence to occurence, select the word then type ⌘e then ⌘g to jump to the next occurence.
Another way is to type ctrls, a little text field appears at the bottom of your window where you can type a word and see its first occurence selected in real time. Repeatly typing ctrls will cycle through the occurences.
Drag a file onto another opened Window
You can drag & drop a file on TextMate's icon in the Dock. You can also right-click the file and choose Open with TextMate *or Open with…*. If you are in a "project" you can right-click and choose Add Existing Files…. Opening multiple files in TextMate will automatically create a "project" for you.
View 2 text windows side by side
I just tried this and it doesn't seem to recognize this functionality. the only time any sort of "add" icon came up was when I dragged the file into an open document and then released, but that resulted in adding the contents of the file into the document.
I just did a quick google search for "textmate split view" and it still doesn't seem to be supported according to some of the answers i found (one from macromates wiki).
Double click on a variable and have all instances highlighted
This also doesn't seem to be supported. This post suggests using the command + f (find), put the word into find, then command + g to jump to the next instance of that word.
There are definitely some things that can be added to textmate to make it more robust. If you are looking for something similar and are on a windows machine, you should check out e text editor. I loved that editor when I was working on a windows machine - split view is supported, but not sure about the highlighting. One thing that e also beats out textmate is the real time regular expression highlighting.
I'm pulling my hair out on this and Google results are skewed since it thinks I want to find out how to code something.
My problem is that when trying to search my code with the String Matching box it finds nothing, even if I enter something that is on the screen below.
Is it Spotlight that is delivering these results? I'm not excluding anything in my Spotlight index so should I just rebuild the index?
At the top of the Xcode search field, you probably want to select:
Find > Text > Containing
rather than any of:
Find > Text > Matching
Find > References > Matching
Find > References > Containing
I did not (knowingly) switch this to "Text Matching" or "References", but there it was set. "Text Containing" is a more useful search type for most searches.
This happens to me after doing this: from editor, select a word, then right-click on it, then choose "Find Selected Symbol in Workspace".
As a consequence, the finder automatically sets itself to:
Find > Reference > Containing
To search for a given text, you have to re-set it to:
Find > Text > Containing
Sometimes this happens to me when the "In Selected Items" is selected in the combobox on the right side of the search string.
If this selected, you only get a search in whatever files are selected in your project window. Change it to "In Project" to search all your source files.
Note that the files need to be inside of your current Xcode project (just opening them from the finder won't add them.) You may also be interested in the "In Open Files" option, which is faster for large projects.
Even with all filters disabled as described in previous answers, Xcode still doesn't always find all occurrences of a string in some of my projects, even though these occurrences are reached just fine when choosing Jump to Definition.
To do a literal full text search (note, this is much slower than the pre-indexed search), you can create a Search Scope that just searches the full project folder, by adding a Folder location in the Scope editor:
I got stuck on this one because I didn't realize that I had to hit RETURN to see the search results, haha. Normally the results changes dynamically as you write, but Xcode 11 apparently doesn't have that feature yet.
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.
Often, when I am reading code or debugging, I want the ability to quickly jump around files. I especially want to "go back" to where I was. I know about "Command+T", "Command+Shift+T", and, bookmarks. But, I cannot figure out a way to jump around files quickly.
UPDATE: I do not think I my question was clear enough judging by two answers given. Specifically, I am looking for a way to "jump back" to where I was in a file. I know how to navigate in TextMate (in general). I want to know if TextMate has a "jump back" key binding.
It's subtle.
The command-T thing has the files listed in Most Recently Used order.
So, you can go command-T return to get back to your last file real quick. At first I couldn't find it either.
I don't think there's a go to last edit location as there is in, say, IDEA/RubyMine.
Courtesy of MacroMates.com
2.3 Moving Between Files (With Grace)
When working with projects there are a few ways to move between the open files.
The most straightforward way is by clicking on the file tab you need. This can also be done from the keyboard by pressing ⌘1-9, which will switch to file tab 1-9.
You can also use ⌥⌘← and ⌥⌘→ to select the file tab to the left or right of the current one.
It is possible to re-arrange the file tabs by using the mouse to drag-sort them (click and hold the mouse button on a tab and then drag it to the new location). This should make it possible to arrange them so that keyboard switching is more natural.
One more key is ⌥⌘↑ which cycles through text files with the same base name as the current file. This is mainly useful when working with languages which have an interface file (header) and implementation file (source).
When you want to move to a file which is not open you can use the Go to File… action in the Navigation menu (bound to ⌘T). This opens a window like the one shown below.
Go To File
This window lists all text files in the project sorted by last use, which means pressing return will open (or go to) the last file you worked on. So using it this way makes for easy switching to the most recently used file.
You can enter a filter string to narrow down the number of files shown. This filter string is matched against the filenames as an abbreviation and the files are sorted according to how well they match the given abbreviation. For example in the picture above the filter string is otv and TextMate determines that OakTextView.h is the best match for that (by placing it at the top).
The file I want is OakTextView.mm which ranks as #2. But since I have already corrected it in the past, TextMate has learned that this is the match that should go together with the otv filter string, i.e. it is adaptive and learns from your usage patterns.
If you have a project window open, you can leave frequently-accessed files open (in tabs), and then use ⌘+1-9 to jump to open tabs.