How can I list all occurrences of a search term in one specific file in VS Code? - visual-studio-code

In VS Code I can find all occurrences of a search term in all project files via the main Search ("Find in Files" -- Ctrl+Shift+F).
This is a nice list of occurrences grouped by filename. However when I have many files in my project, but I am interested only in the occurrences for one file this list is pretty unwieldy.
How can I list all occurrences of a search term in only one specific file?
P.S. I know how to jump inside a file from occurrence to occurrence ("Find" -- Ctrl+f and then Enter), but here I would like a list of occurrences.

To get a list of search matches for a specific file, use the search pane's file filter mechanism and in the "files to include" field, enter the relative path to the file that you want to search in. To see the "files to include" field, you need to expand the little menu (see the "..." button) under the search field. Then just enter a search query like you normally would.

Related

How to show files of a certain name in a panel?

cmd+p shows a list of files matching a certain name.
Is it possible to persist the result and show it in a dedicated panel?
Technically, yes, but in a slightly different format
Go to the "Search" tab, enable regex (the square with an asterisk in the first input box), type ^ (means "start of file/line" depending on regex flags), type the name of the file (use asterisks on both sides for better search), and exclude things like node_modules and .git.
Unfortunately, this doesn't support fuzzy search (like if you type "vsc", Cmdp could find a file named "visual studio code.txt" but this can't), but you can get around that with an asterisk between each character.

How to get a list of all files matching search criteria in VSCode?

As per the answers in this question, there are two primary ways to search for files in VSCode:
By using CTRL/CMD + P/E to search and "go to file"
By clicking anywhere in the explorer tree and typing
Why do the above solutions not suit my needs?
I need a way to search for files and get a full list of them (in plain view) so I can easily scan them.
The 1st method returns only partial results unless I scroll down.
The 2nd method only searches the folder tree that's currently open.
I know I can use the find command in Linux to achieve this, but can I achieve something similar in the editor itself?

Rename error in the eclipse while using the ALT+Shift+R?

I tried to select the word that want to replace for multiple times and it did not. Finally I had to close the eclipse and start it.**
Rename (Alt+Shift+R) is a refactoring option. E.g. this could be used to rename a class or a method without renaming classes/methods with the same name but in different packages/classes if it was selected.
To search replace words in Eclipse within a single file, the replace option is there in the Find/Replace dialog that shows when you press Ctrl+F.
To search replace across files, go to Search/Search (Ctrl+H), and look for the File Search tab at the top (you normally need to scroll the tabs to the left to see it). This will let you search across a range of files, and then replace those matches.

In Eclipse, how can you search within a search result?

"Long live the Unix Pipes".
Since I am working with Eclipse IDE, I would like to perform search within search results. Is that possible? How can I do that?
Ex:
Search for references of User (class).
> Search for validation in this result.
> Finally, search for specific pattern.
This is possible in Eclipse, well as far as the version I am using which is Eclipse Juno 4.2.2; I've used this extensively for impact analysis.
For example:
Search using "File Search" with criteria "employee"
The results will appear in the Tab "Search", assuming you are in the tree view (by default), click the root folder
Again, use the "File Search" this time using the 2nd criteria, for example "default" and making sure to click the Selected resources radio button
Effectively, this searches the keyword "default" from the previous search results produced by searching "employee".
Is it really required?. If you are searching any key in the search results then why don't you use it as search key in previous search itself?.
Eclipse search supports regular expression so you can use multiple search words likes key1 or key2 or key1 and key2 etc to narrow the search results.
Refer this Eclipse File Search Dialog - Regular Expression for Group Unions and Negation
However
You can search in search results with the help of some plugins check here. Take a look at Insta search and glance(Suites for your need) plugin.
Search result can also be exported with the help of this plugin
You cannot. And I am 99% sure of this.
But, just for your info, you can do reference search by pressing Cntrl + G on class name, or method name.

Eclipse searching files in specific package

I am attempting to strip out my Log.i Log.d etc code in eclipse. I have used them liberally. I can find them by control+h and using the File Search tab. Once I can filter the results to a certain package I plan on doing a replace with a blank string.
I check the Regular Expression checkbox.
In the Containing text: field I use Log\..*;
This gets every single Log line of code in the workspace (At least I think workspace, because there is currently 1 project in the workspace)
How can I get this search to only search within a certain package (ie com.example.so.is.super.cool)
I assume this is in the File name patterns field and I have attempted:
.*super.*
*super*
super
Please let me know if there is a pattern I can enter in File name patterns that narrows the search down for me.
Here's how:
Select the package in Package Explorer
On the Search > File Search panel: Specify regular expression, set Scope to "Selected resources"
Press Search