I am using JEdit with the JDiff plugin for file compares. Now I would like to open the JDiff plugin from another tool using command line parameters. Is this possible? So far I was only able to open the 2 files i want to compare in JEdit.
2 Answers
This almost works..... I just can't get the macro to execute after the other files are loaded...
Put this macro in a file.
view.splitVertically();
editPane.prevBuffer();
jdiff.DualDiff.toggleFor(view);
If you on Linux or Mac, put it in ~/.jedit/macros/split_wins_and_jdiff.bsh
. If you're on Windows, put it someplace... ( c:/split_wins_and_jdiff.bsh
maybe?)
Then run:
java -jar jedit.jar -noserver -norestore \
-run=$HOME/.jedit/macros/split_wins_and_jdiff.bsh\
file_on_left file_on_right
The problem is, I can't get the macro to run after initialization, so that method results in an error. If you're ok with doing a two step process, then you could do:
Setup
- Install the above macro in your macros area (
~/.jedit/macros
for linux, mac) - Create a shortcut for the macro:
- click Utilities -> Global Options
- in panel on the left, select "Shortcuts"
- in the filter, type "split_wins_and_jdiff"
- double-click on the cell to the right of "split_wins_and_jdiff" and below "primary shortcut"
- do a command sequence ( my macro command sequences always begin with ctrl+m. I think that is a JEdit convention... )
- save shortcut by clicking the "Ok" buttons
How to Use
Whenever you want to quickly jdiff two files: * Open the two files:
java -jar jedit.jar -noserver -norestore file_on_left file_on_right
- Right after jedit loads, run your macro with the shortcut you created.
Without Macros
Btw, you can do all this without the macro, if you create a shortcut for JDiff ( for me it is ctrl+shift+d, d)
Open the two files:
java -jar jedit.jar -noserver -norestore file_on_left file_on_right
Split the screens vertically
ctrl+3
On the right screen ( which is now selected after the split), cycle to the other buffer with ctrl+page-up.
Turn on JDiff with your shortcut ( for me ctrl+shift+d, d)
Creating macros in jedit is dead simple. You can simply record them and they'll popup in a new buffer where you can view the actual macro code. This is what I did to create the macro. Try exploring the macro menu and macro usage.

- 23,523
- 27
- 108
- 164
I realize this is an old question, but I ran into this the other day. I built on the idea of running a beanshell script like in Ross' answer. I believe I got everything to work (without having to manually run the macro), and thought I'd contribute here to say "thanks" for steering me in the right direction.
Here's my whole setup for getting jEdit to diff from the command line, and it includes using jEdit as the "difftool" for Git.
PS: I wanted to make this a follow-up to Ross' answer, but I'm new here, and didn't realize I needed currency to comment on an answer.

- 11
- 3
-
Thank you. Steered me in the right direction for something related 4 years later. – lucid_dreamer May 09 '17 at 19:37
-
This should be the right answer - but can you explain in particular why your solution doesn't suffer from the problem Ross has in [this answer](http://stackoverflow.com/a/4158013/1712447): _The problem is, I can't get the macro to run after initialization_ – lucid_dreamer May 09 '17 at 19:49
-
1Four years after a three-year-old post. Sweet! IIRC the files are actually loaded before the script runs, but the edit pane in which they live is not yet set as the "active" edit pane (or something). My script searches all the buffer sets until it locates the file buffers of interest, and makes sure those panes are active (which allows jDiff a chance at doing its job). If you wait a while, those panes become active on their own. But, I could be wrong. That's all from memory. I moved back to Vim a few years ago, and my brain has been turned to mush hacking VimL scripts. – Z. Hester May 10 '17 at 22:15