I have 2 windows open: One is the magit-diff of the current repo, the other is just source codes from that repo. In source codes (the right window), I have a file opened, say "sample.txt". In magit-diff (the left window), I can see all of the deletion and insertion that occur for "sample.txt". In other words, it looks like this:
| magit-diff | "sample.txt |
| modified sample.txt | |
| + text I added | |
| - text I removed | |
Now, if I press enter on the line "+ text I removed", then I would be taken straight to "sample.txt" at the exact line where the insertion/deletion happens. The only problem is that this would open another buffer that overlays the current magit-diff buffer. The original window for "sample.txt" does not change. In other words:
| "sample.txt" | "sample.txt" |
| cursor at line of inseration/deletion | |
| | |
| | |
I do not want this to happen. What I want is once I press enter in magit-diff, I would like the other window (the right window with "sample.txt" already opened) to jump to the line of insertion/deletion. If "sample.txt" is not already opened yet, then just open the file in another window. In other words, after pressing enter:
| magit-diff | "sample.txt" |
| modified sample.txt | cursor at line of insertion/deletion |
| + text I added | |
| - text I removed | |
Is there a way to do this within emacs? Please let me know and thank you for your help.