How do I save a file using the Eclipse compare editor - eclipse

I can't seem to find a way to save the changes I make to project files using the two-way compare of two local project file folders. I can step through the differences and copy changes from left to right, but there's no way, as far as I can tell, to save those changes. I looked at the files outside of Eclipse after I copy changes left to right and they are not being updated.
Here's a help site explaining what I'm doing http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-25.htm it sayz 'You can save changes to resources that are made in the comparison editor.' but doesn't say how...
I can just copy and paste the contents of the merged file into a new editor window but this seems like a silly way to go about this. I guess I could also create a diff patch and apply it to my project as well...

It seems that using *nix command diff is a piece of cake:
diff -rupN original/ new/ > original.patch
as stated in the "The Ten Minute Guide to diff and patch"

Related

How can I search for a file in just one specific folder in VSCode when using a workspace with multiple folders?

I'm using the workspace feature of VSCode, with two projects, but it's annoying to search for a file in the front-end project and need to pass by back-end files to find the one I want.
I'm using ctrl + p to search for files.
How can I search for a file in just one folder with multiple projects opened in the workspace?
Yes thats possible: use a relative path: ./mySearchedProjectName in "files to include"-input
from HERE!
UPDATED answer to UPDATED question
The fuzzy file finder (CTRL+P or ⌘+P) somehow supports prefixing the filename with a folder, such as folder/filename to locate a file from a specific folder:
But, in my experience, the search is a bit lacking. For example, I find it usually can only find files this way if that file has been recently opened in your workspace. It also does not support regex.
The best thing that can be done is to enable including recently opened files by adding this to the workspace settings:
"settings": {
"search.quickOpen.includeHistory": true,
AFAIK, there is no other built-in way to filter the results. There are (still) open feature requests for this, like this Allow quick open to filter on folder names by typing folder name after the file. You can thumbs-up them to hopefully get them noticed.
ORIGINAL answer to ORIGINAL question
I don't know what you mean by "projects" since VS Code only has "workspaces" and "folders", such that you add folders to a workspace. I think you're already doing this, where each folder contains a separate set of codes.
With that said, the Search/Find panel has an area to specify files to include, where you can limit your search to a specific folder. For example:
Here I have 3 folders (proj 1-3) added to a workspace. I have 3 sample files with the same text.
When searching, you can set files to include to a specific folder (./proj2), so that the search results will be limited to that folder.
I've found the best solution to this for me (though it's still a sub-optimal one) is simply to run multiple VS Code instances, one for each folder.
It's a pain to start up, but once you get things going (and hopefully you're not restarting often on your dev machine, so this is less of an issue) it works perfectly: you can search for files with only the relevant ones showing up.
Also, if you want to reduce the start-up pain you can make a shortcut/alias/etc. in your operating system that starts both at once.

Eclipse: How do I restore the original project structure?

After checking out a very old commit of a project, I checked back out to the current state of the project. However, this somehow messed up my directory structure in Eclipse. Here is what the structure was before (and what I need it to be now):
And this is what it currently looks like:
So here are my questions:
Is there some quick and easy fix to get the directory structure back to how it was? It seems like Eclipse still "remembers" what the structure looked like, but misinterprets it.
Why did this happen in the first place and how can I prevent it form happening again? A few others I know had the same problem (which made them promptly switch to InelliJ rather than fixing the issue).
Thanks in advance!
It seems that the project folder is wrongly set as source folder.
This can be corrected in Project > Properties: Java Build Path, in the tab Source: select the source folder Quoridor, click Edit... and enter src.

How to merge files(differentiate) in visual studio code

I am using Visual studio code for angular2 application. The requirement is to merge files, so, I want to differentiate changes in two files as it happens in Netbeans IDE. Is there, any extensions available to achieve the task in visual studio code.
For e.g - Merging Two files by differentiating changes like below:-
Please suggest some solution.
abc.component.ts (located in project1)
abc <-- text for understanding purpose
def
abc.component.ts ( located in project2)
abc
I want to differentiate two component files and push changes in another like it happens in Netbeans IDE? Is there, any solution available for Visual studio code?
First using vscode natively with the git toolset
(Make sure to look on the second title as it's a better native way!)
This way may be available on older version of vscode too! Still a good thing to know! (even we should always run on the latest version! And vscode is always keeping getting better and better).
A native powerful and cool way is to use the git toolset within vscode! It still not the most fluid way! But if you are in a setup where you don't have anything else or time or resources to use anything else! Also as a requirement you need to have a git repo initiated! Here we go:
First we will use the change and diffing capability of the git tool set. And the steps go as bellow:
Commit all the current changes
once done: copy past the other file to diff on the place of the current one. And save.
Cool now in the git pallet you can see the file in changes list! Click on it and the diffing editor will show!
Bingo this is it! You can compare and make direct changment! The diffing will keep happening in real time. Note the current state is in the right. And you make changement there.
Here an illustration of direct modification for instance the part in the left is missing from the current file
And here another illustration (current have in plus)
Well to sum up! Git tool and diffing in vscode is so powerful! And all that one need! The only problem is the extra step of committing and cleaning after if desired!
Here some tips! If you want to have the commit history cleaner! Or not have a merge separate! You can remove the last commits from history as much as you need: Without hard reset and commit again a cleaner one!
git reset --soft HEAD~1
You can check
How to cancel a local git commit
Otherwise it can be ok with atomic commit and merge mention!
Also if what you need is to be able to keep a lot from the current file! You can copy the current elsewhere! past the other file to compare! commit ! and then past again the old one! You'll have the old in the right and as current (Not as described on the above) In such a scenario this work well! (Hacky a bit but you may need it).
Native way (direct open of the compare editor)
(May require the newer version of vscode)
open a file that you gonna compare
open the command pallet
CTRL + SHIFT + P
type file: compare
You can see the different possible ways! For a file we can choose compare active file with.
Then you choose the file! The file need to be within the project directory.
And then you choose a file and the compare editor will open
The above was tested on my brother computer on a new vscode installation. I wasn't sure at first if it was part of the core! And i just confirmed that it is. That too remove the need to the method above involving git! And it's the best native way to go with.
Vscode extensions
Here two extensions i suggest the first:
https://marketplace.visualstudio.com/items?itemName=jinsihou.diff-tool
Easy and simple! It add two elements to the right click menu:
In current file right click -> Select as first file for diff, select one again to view the diff results
select to compare and compare with select no more simple then that !
Another extension to check:
https://marketplace.visualstudio.com/items?itemName=fabiospampinato.vscode-diff
I prefer the first! As this one compare a lot to the native way. And having the control in the contextual menu is just great.
Out of vscode! Using other tools
A quick google search and you'll find a lot of tools!
https://meldmerge.org/
meld merge is cross platform and open source and nice!
in linux and debian:
sudo apt install meld
Otherwise you can check the long list here:
https://www.jotform.com/blog/25-useful-document-and-file-comparison-tools/
https://stackify.com/code-merge-tools/
There is too winMerge to mention (an open source project for windows)
https://winmerge.org/

Eclipse target definition is empty

For some mysterious reason all the target definition files (*.target) in my plugin project became empty.
I have absolutely no clue how to fix this.
With the information provided in the question it is difficult to guess the reason.
However you can try these
Open target file in Text Editor and check the content.If the size of the file is more than zero then you can see some content here.
If using any SCM tool get the older version of these files.
You can replace the file content in local history. Right click on the file go to Replace with > Local History then choose the older one and click Replace.

Tool to compare and merge files in different folders

I am developing two Java based projects that are very similar which means that what i do to the first one i can use diff to... command in Netbeans to apply the changes to the second one. However there is a problem with the images folder. For example i work one week on the first project and during this week i put 34 new images in the images directory. Then i have to put some of this images in the images directory of the second project. Copy/paste is not a solution because the projects are NOT EXACTLY THE SAME.
That is why i need you to recommend me some tool that can show me which pictures are missing in the seconds directory so i can simply drag them to their new location:)
diff -rq <path1> <path2> will give you a list of files that are only in one of the paths, as well as an indication of whether file names that exist in both actually have the same content.