Simple eclipse search problem - eclipse

I use the eclipse File Search option very much to search all files in my workspace for a certain content. But how do I specify that it should only return hits from a fixed search criteria? As an example I would like to find all occurrences of the string:
com.mystuff.data
but I also get all the hits for:
com.mystuff.data.ui
How do I make a "this-string-only-search" when searching files in my workspace??

If I understand you correctly, Eclipse don't provide option to search exact word.
You can use regular expression for it.
You can use \bSearchKeyword\b to find exact word.

I suggest that you use regular expressions.
Here are the steps:
Select the checkbox "Regular expression" which is located beside the "Containing text" field.
In the "Containing text" field write: com.mystuff.data\D\W
Note that:
\D means "no digit"
\W means "no alphanumeric"
In case you would like to refine the regular expression, click Ctrl-SPACE, in order to get the regular expression assistance.
Hope this helps.
Best regards

Maybe slightly off-topic but this got me tripped and brought me here - maybe useful for somebody else:
In the Eclipse standard Find/Replace dialogue the section 'Options' (that includes the option 'Whole Word') may be hidden if the Find/Replace dialogue window was previously resized to a smaller size, without any clue to its presence. Resizing it larger brings back the options section. See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=355206
and attached shots.
Eclipse standard Find/Replace dialogue search for Whole Word regards several characters (including period) besides a space as a word delimiter, so you indeed cannot distinguish between "com.mystuff.data" and "com.mystuff.data.ui"
E.g. search 'Stack' with option 'Whole Word' checked:
will match:
Stack
Stack overflow
Stack.overflow
Stack,overflow
Stack[overflow]
Stack(overflow)
Stack-overflow
Stack/overflow
will not match:
Stackoverflow
Stack2overflow
Stack_overflow

Simplest way is to add space in the start and end of your search term.

Try SHFT+ CTRL+R, then on right upper angle select Working Set, then name and specify your resources.
Create Work Set as above, then CTRL+H check checkbox All occurency, then select your Work Set. Or maybe you can create work set in CTRL+H.

Related

Search for an exact phrase with InstaSearch for Eclipse

How can I search for an exact phrase in Eclipse instasearch?
When I search for
one two
it will find also files that contain only one. And the file containing the exact phrase is not at the top of the result list.
UPDATE:
#Ad Infinitum suggested to turn off the option:
Find similar matches when no exact matches found
but strangely it does not work as you can see from the screenshot:
Instasearch is already looking for the exact match. However, if it cannot find an exact match, it looks for the alternatives. If you only want to display the exact match, there is an option, which you can unmark the fuzzy search, in the instasearch's preferences.
In order to get the instasearch's preferences.
Window -> Preferences
when the Eclipse's preferences dialog is openned, you can write instasearch in the search text field, which brings you the instasearch preferences.
I hope that is the option, you are looking for.
EDIT
When this option is unmarked, the results will be something like that if there is no match. 0 matches and under of it, there is more selection, which shows the fuzzy search results.

Replacing a string in Rubymine with a string with newlines

I want to use the Search and Replace dialogue in Rubymine, or something similar to replace something like "Scenario:" with "#Desktop\nScenario"
I'm trying to replace every instance of Scenario: in a large Cucumber test suite with
#desktop
Scenario:
Any best ways to do this?
Update:
Thanks to #ryan2johnson9 comment, I realise there's now an easier option (tested on 2017.3).
By clicking on the "New Line" (or using the shortcut Ctrl+Shift+Enter / Alt+Enter), the input becomes multilines.
Original Answer
In the search and replace box, if you tick the "Regex" option you can do:
Search: "Scenario:"
Replace by: "#desktop\nScenario:"
The only trick is to tick the "Regex" option :)
Rubymine has macros (http://www.jetbrains.com/ruby/webhelp/binding-macros-with-keyboard-shortcuts.html) but I dont think they are powerful enough for this example.
It's possible that you could solve it with some elaborate feature hidden inside Rubymine, but I think it would be a lot easier to do this with a tool like perl/sed from the Terminal. If you are using Windows I assume you could search the net and find a text search/replace tool that fits your need.
In OSX I there are a bunch of Text Substitutions app too.
I would go that route since Rubymines macro tool isnt up to the task.
Here's a cheap and sleazy alternative:
Copy a newline character from between two empty lines in the file being edited. Temporarily add two empty lines if you don't have any.
Set up search/replace and enter the string you want to replace into the search text input box.
Paste the newline you just copied into the replacement text box plus whatever other text you want. You will be able to see the height of the replacement text input box grow vertically by one line due to the newline.
Perform the search/replace.
For this, the use of the Rubymine regex is optional.

Find and Replace in Xcode Using Regular Expression

I'm wondering, is there a way that you can do a search for all words that have the word "pPath" in them and replace them with "mutablePath" in Xcode. For instance, there are certain instances where there could be pPath_0 or pPath_50, I just want to replace them all with "mutablePath". Is there a regular expression I can use for this if it's possible?
EDIT #1: I mean to actually replace the whole word pPath_50 or (any word that has pPath in it) with mutablePath. Doing a simple find and replace will only replace the word "pPath" with "mutablePath".
EDIT #2: I found out that if you click the magnifying glass next to the search bar, then click "Show Find Options", you can select "Regular Expression" from a pull down menu and use it to do a search for a regular expression. I'm assuming that the regular expression language used for this is common to other things, does anyone know what the regular expression is to search for any word that has pPath at the beginning of it?
I found that you actually can use regular expressions on find and replace in Xcode 4.3. Simply click on the magnifying glass next to the search box (or the area where you enter in the text to search). Select "Show Find Options", then under "Style" choose "Regular Expression". I'm not too familiar with regular expressions, but I believe it uses syntax that is similar to a lot of other modules that implement them. For instance, I was able to solve my problem using "pPath_\w*".
Yes - Go to Search Navigator (left pane) - Click on the drop down for 'Find' and you will see replace.

ignore differences in syntax in beyondcompare

In a branch of code I have changed all of the code from obj.varname to obj("varname") and when I compare the code I would like to ignore these differences since varname is the same.
I have a regular expression that I think I need but unfortunately can't get the comparison to be ignored using Beyond Compare from Scooter
^obj\("\w*"\)|obj\.\w*$
I am following this tutorial http://www.scootersoftware.com/support.php?zz=kb_unimportantv3
So my question: is this even possible with beyond compare? If yes, please share a solution including either instructions or post your screenshots.
Beyond Compare 3's Professional edition supports this through its Text Replacements feature. If you've already purchased a Standard edition license you need to revert to trial mode to test it: http://www.scootersoftware.com/suppo...?zz=kb_evalpro
Load your two files in the Text Compare.
Open the Session Settings dialog from the the Session menu, and on the Replacements tab click New to create a new replacement.
In the Text to find edit, use (\w+)\.(\w+)
In the Replace with edit, use $1("$2")
Check the Regular expression checkbox.
The alternative would be to mark any instance of obj.varname and obj("varname") as unimportant. The basic steps would be this:
Load your two files in the Text Compare.
Open the Session Settings dialog from the Session menu, and on the Importance tab click the Edit Grammar... button.
In the next dialog click the New... button below the top listbox.
Change the Element name field to something useful (say, "PropertyAccess").
Change the Category* to List.
In the Text in list* edit, add these two lines:
obj.varname
obj("varname")
Click OK to close the Grammar Item dialog and then click OK again to close the Text Format* grammar item.
Uncheck "PropertyAccess" (or whatever you named it) in the Grammar elements listbox in the Session Settings dialog, then click OK to close it.
This approach isn't as flexible or clean. In the steps above you're matching specific, hardcoded object and variable names, so obj.varname is unimportant but obj.othervar isn't, even if it's aligned against obj("othervar"). If text on both sides is unimportant the difference will be unimportant; if one side is important it will be an important difference. So, with the above steps, obj.varname and obj("varname") will be unimportant everywhere, but it will work correctly since they'll either be matched to other cases that also match those definitions (and thus unimportant) or will be matched to something else that doesn't match that definition, which will be important and will make the difference important.
You can use regular expressions to match more general text categories, but you probably don't want to. For example, if you wanted to match all text that followed that pattern you could use these two lines instead:
\w+\.\w+
\w+\("\w+"\)
And then check the Regular expressions checkbox in the Grammar Item dialog so they're matched that way.
The upside/downside to that is that any text that matches those patterns is then unimportant. abc.newvar vs. def.varname would be considered an unimportant difference because both sides match the unimportant definition. That's good for things like comments or whitespace changes, but probably isn't what you want to do here.

Word/Line count tool in Eclipse

Is there any tool or plugin can do this? CodeBlock has this neat tool which is really nice. Wonder if it's available on Eclipse. Thanks.
http://metrics.sourceforge.net can do lines. I'm not sure about words however.
For newlines, use file search, and search for \n (with regular expressions enabled) in all of the files you want.
For words, you can just make your search term for \w+
The count is the number of matches! If you want anything fancier, make a fancier regex.
Source: http://www.binaryfrost.com/index.php?/archives/207-Easy-way-to-count-Lines-of-Code-in-Eclipse.html
Linenumber is always displayed on the lower right corner, and left if you use the context menu an left side of your edit window and check "Show Line Numbers".
Google>: "eclipse word count" shows that many people had the same problem and developed plugins.