How to compare two files in Eclipse? - eclipse

I want to compare two files. One is in the current project and the other is in the backup directory. I know how to compare if they were in the same project.
How can I compare in Eclipse?
And what is Flex navigator in Eclipse?

Open the Navigator with the Main menu: Window->Show View->Navigator.
You can select two or more files in the Navigator using Ctrl-click, or Command-click in OSX. Now Right-click any one of the selected files, and select the menu item: Compare With->Each Other.
The problem is that your alternate file might not be in the Navigator, e.g. your backup directory isn't listed in the Navigator. If not, Right-click in the Navigator and choose the menu item: New->Folder. In the resulting dialog click the Advanced>> button beneath the Folder Name field, choose Link to alternate location (Linked Folder), and browse to add your backup directory.
Now using the Navigator you'll be able to select the two files, and use Compare With.
You can similarly compare files using e.g. the Package Explorer.

Related

vscode: Search in a directory which is outside the workspace

I want to search in a directory which is outside my workspace.
Steps:
I open a file which is outside my workspace.
Now I want to search in the directory which contains this file.
I use "Reveal in Explorer" and try to use the breadcrumbs, but I see no way to search in the directory.
I use Go, but AFAIK this should not matter for this question.
As it happens another extension I wrote makes this pretty easy: Find and Transform.
It adds three context menu entries:
Search in this Folder
Search in this File
Search in the Results Files (if there has been a previous search with results)
You can right-click on any tab or editor body and select Search in this Folder and it will populate the files to include input box of a search with that file's parent folder path.
And if you have any text selected, the query field will be populated with that selection (even if it is just a cursor in a word).
You could also just right-click on that tab and chose Copy Path, paste that into the files to include input of a Search and then delete the last part of the path back to the folder.

How to use Eclipse to hide some java files to compile?

When I am using Eclipse, I want to know if I can use any tools so that I could hide some of my files so that they would not include in the compiling. There are many java files in the project containing the main function, so I just want to know if there are some tools which can hide some of the files.
Right-click on the project in the package explorer
Select "Build Path" -> "Configure Build Path...".
On the "Source" tab on the right you see all source directories. Expand the relevant ones (if they aren't already expanded) and select either "Included" or "Excluded" and click the "Edit" button.
Then you can either select sub-directories with "Add Multiple..." or add some patterns matching the files names you want with "Add..." in the respective sections.

Eclipse open all files in project

How can I open all source code files in a eclipse project at once? It takes too long to open all files in large projects by expanding out the packages and clicking on all the files.
I would like to know how to do this so I can ctrl+e to classes quickly.
It is not a good way to keep open all source files in a project because a project may have hundreds of source files. There is NO direct way to open all source files in eclipse.
However you can do it in two ways:
Using open resource dialog:
Create a working set which includes your project. Refer this.
Press Ctrl+Shift+R and select the your working set(Click on the downward pointed triangle button)
Type *.java in the text box. Dialog will list all java files in your project. Press Ctrl+A to select all files. Click on open button.
Using search dialog:
Select your project in Package explorer/Navigator/Projects view.
Press Ctrl+H. Go to File search tab. Leave "Containing text:" as blank. In File name patterns text box enter *.java. In scope section choose Selected resource option. Press search button. All source files will be displayed in search view.
Change the view layout of Search view to Show as list(In search view toolbar click on the downward pointed triangle button)
Press Ctrl+A to select all results. Right click and select open option.

How do I compare two files using Eclipse? Is there any option provided by Eclipse?

How do I compare two files using Eclipse?
(Currently I am using WinMerge.)
To compare two files in Eclipse, first select them in the Project Explorer / Package Explorer / Navigator with control-click. Now right-click on one of the files, and the following context menu will appear. Select Compare With / Each Other.
Just select all of the files you want to compare, then open the context menu (Right-Click on the file) and choose Compare With, Then select each other..
If one or both of the files you wish to compare isn't in an Eclipse project:
Open the Quick Access search box
Linux/Windows: Ctrl+3
Mac: ⌘+3
Type compare and select Compare With Other Resource
Select the files to compare → OK
You can also create a keyboard shortcut for Compare With Other Resource by going to Window → Preferences → General → Keys
Other than using the Navigator/Proj Explorer and choosing files and doing 'Compare With'->'Each other'... I prefer opening both files in Eclipse and using 'Compare With'->'Opened Editor'->(pick the opened tab)...
You can get this feature via the AnyEdit eclipse plugin located here (you can use Install Software via Eclipse->Help->Install New Software screen):
http://andrei.gmxhome.de/eclipse/
If your compairing javascript you might find it not displaying.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=509820
Here is a workround...
Window > Preferences > Compare/Patch > General Tab
Deselect checkbox next to "Open structure compare automatically"
Compare with Other Resource – The Easy Way using Eclipse (no additional plugin required)
To assign a keyboard shortcut to the feature, go to Window > Preferences > General > Keys, look for the command Compare with Other Resource and assign it to a keyboard shortcut of your liking. See How to manage keyboard shortcuts in Eclipse for more details on configuring shortcuts.
Tip: Alternatively, you could press Ctrl+3 (for Quick Access) and search for Compare with Other Resource. This way you don’t have to configure a shortcut but you’ll have to search for the command every time in Quick Access.
Once the shortcut is assigned, you need to select the source file from the Package Explorer, Project Explorer or Navigator. The easiest way to do this from an open editor is to assign a shortcut to instantly show the file in the Package Explorer or, if it’s not open, to open it quickly using the keyboard.
Now press the keyboard shortcut you assigned to Compare with Other Resource and the following (non-modal) dialog should appear:
Troubleshooting: If the dialog doesn’t appear, it’s probably because you haven’t selected a file in either the Package Explorer or another view that allows file selection. Make sure a file is selected and make sure you haven’t selected the class in the Package Explorer rather than the actual Java file.
Now you can select the second file in the Package Explorer and drag and drop it onto the dialog. Click OK and the comparison editor should display, comparing the two selected files.
Tip: See the post on using shortcuts for common SVN commands for tips on how to navigate the comparison editor with the keyboard.
Comparing External Files
Using the Compare with Other Resource dialog, you can compare a workspace file with an external file or even compare two external files with each other.
Comparing a workspace file with an external file is easy: Once you’ve opened the dialog from a selected file, instead of dragging and dropping another workspace file, tick External File in the Right pane and then Browse to a file on your filesystem.
To compare two external files, you have to start the dialog again from a selected workspace file (choose an arbitrary file). Once open, select External File in the Left pane and Browse to your file then do the same for the Right pane.
Please refer this page for more details: http://www.eclipseonetips.com/2013/09/19/compare-two-workspace-or-external-files-in-eclipse/
If you have Beyond Compare installed, the ContextQuickie eclipse plugin has an option to enable it to be selected from the context menu displayed when you right-click a file.
Install from:
https://github.com/ContextQuickie/ContextQuickie/wiki/Installation
After install, activate Beyond Compare menu items via Window->Preferences->Context Quickie->check 'Enable Beyond Compare'.

Copy files from search tab in eclipse 3.4

I just want to copy list of files displayed in eclipse search tab,
When i try using right click copy and paste into some folder it does not work.It actually copies the file location rather than the file itself
There is no direct way to do this. What you can do is:
Double click on the entry in the search tab
F12 to switch to the editor
Ctrl+Alt+W to select the file in the navigator view
Drag the file from there to the place where you want it
Too tedious? Then open a command prompt or shell and use the file location there.
If you need file locations then use Eclipse search csv export plugin.
If want to copy the whole file(s) into a folder then refer #Aaron Digulla answer(Its applicable to single file). In case of multiple files. Press Ctrl + A to select all search results in search view. Right click on the selection. Choose Show In > Package Explorer. Drag file(s) to a folder in any file explorer.