jEdit Community - Resources for users of the jEdit Text Editor
Send Selection To ...
Submitted by Kel Solaar on Friday, 4 July, 2008 - 07:53
Hello o/
I'm currently trying to write a macro to Send Selection To Python, but I need some help to improve the stuff : I would like to be able to switch back to make active the previous buffer (the one the selecton came from) and the best would be maybe to do that in a transparent way without having the file popping into jEdit. I tried with the jEdit.openTemporary(); but didnt figured how to make it work. Some help would be really appreciated Smiling Here is the simple macro so far :

// Send Selected Text To Python
String pythonPath = "D:\\Softwares\\Developpement\\Python25\\pythonw.exe";
String currentFile = "D:\\_Temp\\";

Buffer newBuffer = view.getBuffer();
Registers.paste(textArea,'$',false);, currentFile);
runInSystemShell(view, "\"" + pythonPath + " -t \"" + currentFile + "\"");
How to parse HTML/DOM to set ID attributes
Submitted by takeshin on Thursday, 19 June, 2008 - 09:23
I want to write a macro to automatically add id attribute for all specified tags (h2, h3, h4…),
when it is not set yet. (for example #h2-1, #h2-2, #h2-3…).

I wrote a simple javascript bookmarklet to do it,
but I dont’t know how to do it in beanshell macro.
Set IDs bookmarklet

How to write getElementsByTagName(tag) function?
Maybe just regular expression with returning beanshell replacement will work?
Then how to increment those IDs in regexp?

Collating file names - basic help.
Submitted by PaulCollingwood on Friday, 6 June, 2008 - 11:50
Can anyone demonstrate a macro script that collates an array of filenames that match a certain extension within a specified directory path?
I would need a specific example of how to access each array item, and to know how many array items there are.
This does NOT have to recursive.

Thanks in advance,
File manipulation - what's wrong with this macro?
Submitted by PaulCollingwood on Friday, 6 June, 2008 - 11:41
Hi, I'm trying to collate the names of all the files within a specific directory path with a specific extension. My bsh macro file contains the following: --------------------------------------------------------- class OnlyExt implements FilenameFilter { String ext; public OnlyExt(String ext) { this.ext = "." + ext; } public boolean accept(File dir, String name) { return name.endsWith(ext); } } example() { file_path = "/example/mydir"; File f1 = new File(sys_file_path); FilenameFilter only = new OnlyExt("bak"); // This is the OFFENDING LINE!!! String filtered_files[] = f1.list(only); for (int i=0; i
Move to text area from console
Submitted by ernest on Friday, 23 May, 2008 - 01:16
I have a macro that I use to save my current document to disk and then to the server on which I am required to launch builds. This all works fine. But when I do a save, the macro runs (running ssh) and the cursor ends up in the Console. How can I have the cursor jump back into the text area where I am working?

Also, the act of saving causes any errors in the Error List to be cleared. I can understand this given that Console does the error parsing, but is there some way I can tell Console not to clear the Error List?


Need help with macro to toggle tab size
Submitted by ernest on Tuesday, 20 May, 2008 - 04:58
How would I create a macro to toggle the tab size between 4 and 8? I tried to start one by recording a macro while I changed the tab size using the buffer options dialog, but the resulting macro only showed this: new BufferOptions(view,buffer) - which just brings up the buffer options dialog. I'm not sure now how to proceed. I want to learn how to write good macros, and eventually plugins, so I'm hoping for advice rather than a complete solution. But any help at all will be appreciated.


adding shortcut to a macro
Submitted by ianbd on Tuesday, 22 April, 2008 - 13:01
I have some simple macros to which I want to add consistent shortcut keys as part of the install.

I assume that I use the jEdit.setProperty option with something like:
jEdit.setProperty("my_macros/macro1.shortcut", "CA+1"); but that does not work.

When I check the global options, the shortcut is recorded as the literal string, but Ctrl + Alt + 1 does not activate the macro.

Does anyone know how to set such a shortcut? For example, is there some form of key combination code that I need to enter to get this combination to work through setProperty()?

Thanks in advance...
How do I determine whether a file exists?
Submitted by PaulCollingwood on Thursday, 17 April, 2008 - 15:43
I'd like to write a macro for jEdit which runs an external application, and in doing this I wish to check whether a file at a specified path exists, and conditionally execute macro content on this basis.

Does anyone know how this is achieved?

Thanks in advance!
JDialog modal doesnt seem to work in bsh macro
Submitted by drefty on Thursday, 17 April, 2008 - 12:54
Does anyone have a script that demonstrates how to use a Modal dialog from within a Beanshell macro?

Problem: I am trying to get user input in a beanshell script and set a variable based on that input. The problem is when I set modal=true for the JDialog box, the JDialog no longer disposes after presses of "OK" or "Cancel". The dialog just sits there and won't go away, therefore I cannot capture the result and set the variable.
Open Search & Replace Dialog
Submitted by andyc on Monday, 4 February, 2008 - 21:56

I have what I hope is a simple problem...

I am writing a basic macro to find the next occurrence of the currently selected text. Something along these lines already exists and can be downloaded using the Macro Manager plugin. What's new in my version is that I would like to have the Search & Replace dialog be displayed if no text is currently selected. (That way, I can map it to Ctrl+F and still access the dialog via this shortcut.)

I couldn't find much info on this and what I did find seemed to refer to the "SearchDialog.showSerachDialog" method that doesn't seem to exist any more. I would be most grateful if someone could point me in the right direction.

Many thanks,

Run Macro on Shutdown?
Submitted by MasterT on Tuesday, 8 January, 2008 - 15:12
Is it possible to run a macro when I shut down jEdit? I know we can throw them in the startup directory to be run on startup, but what about when we shut down?
How to use SearchAndReplace in a loop?
Submitted by tvojeho on Wednesday, 21 November, 2007 - 16:59

I have been using jEdit for a few months now, and it is an awesome editor. I have written a few macros, but I do not know Beanshell very well and now I am stumped.

I want to write a macro to correct some words using SearchAndReplace command. I would like to be able to define the words to be searched and replaced, and then to run a loop, where the replacements happen. I am vaguely aware of things such as arrays and maps, and I think in my case I am going to have to use one of those, but I don't know where to begin.

This is an example of how I want it to work (just a concept, not a working code):

//Define search and replace pairs
searchReplacePairs[] = ("thats","that's",

//Grab each pair and perform replace
Loop searchReplacePairs
SearchAndReplace.setSearchFileSet(new CurrentBufferSet());

As you can see, I do not know how to define the array, then how to parse it to get the textToSearch/textToReplace pair and process it in the loop. Any help would be welcome.

Thanks, tvojeho
Syntax highlight
Submitted by gregus on Tuesday, 23 October, 2007 - 06:52
How do I get to the class or method that control the Highlight. when you save as "" the extension will know that it is a java program other extensions are Java,xml,php, perl.etc. example of what I am saying is below.

public SyntaxStyle getStyle()
return null;
Color foreground = (fgColorCheckBox.isSelected()
? fgColor.getSelectedColor()
: null);

When I save a new file as "" Those color on public, getsysle etc. should not appear again.

I have tried all the GlobalOptions, SyntaxHillit, and others I cannot find it. I am a babe learning.
Return xpath of selected xml element or attribute
Submitted by paulflory on Saturday, 29 September, 2007 - 01:05
Hi all, Is it possible to write a macro that can return the xpath of the element or attribute the cursor is located at? For example, given the following xml document, and assuming the cursor is located on the Target element, the macro would return the string: /Links/Link/Target /htdocs/images/coffee_cup.jpg I can not find this functionality in the XML plugin or elsewhere. Possible? Thanks, Paul
selecting text from current position till a pattern to search
Submitted by rsc on Monday, 3 September, 2007 - 11:35
I often have the task to select or delete a text (more than one line) from the actual position till a pattern to search for. If you know UEDIT there you can press "shift" and initiate the search. All the text from the current position including the string found will be marked.

I accomplished this by recording a macro and manipulating the Java code afterwards. However, if you are recording a quick macro this is much too intricate.

What did I miss?

Thanks for your help, Rolf.
Creating a macro that configures Buffer Options and ConfigurableFoldPlugin
Submitted by mbisping on Tuesday, 7 August, 2007 - 13:38
Hi there, I'd like to have a macro that sets the buffer option folding to custom and configures the ConfigurableFoldPlugin to use
Creating a macro that configures Buffer Options and ConfigurableFoldPlugin
Submitted by mbisping on Tuesday, 7 August, 2007 - 13:27
Hi there, I'd like to have a macro that sets the buffer option folding to custom and configures the ConfigurableFoldPlugin to use
IDE for writing jEdit BeanShell macros?
Submitted by Giesen on Tuesday, 5 June, 2007 - 15:51
Currently, I'm getting started writing jEdit BeanShell macros with just a simple text editor and the online User's Guide as a reference. Is there a better way?

Is there any IDE that could provide auto-complete, context-sensitive help, syntax check as I type, and other modern IDE goodies? Or is a plain text editor the way to go?
How to get the string of line comment token(s)?
Submitted by galou on Thursday, 10 May, 2007 - 09:47

I try to write a macro that insert a new line of comment, indenting it and adding the space between the comment token(s) and the text, as on the previous line.

For the moment, I use only '%' as comment token and hard coded it. To submit the macro, I would need to know how to get the string of line comment token(s).

Can someone help me?
How to return the Console's process code?
Submitted by stretch6555 on Tuesday, 10 April, 2007 - 05:49

I've been trying to write some simple beanshell code which calls some methods from the Console plugin. In one part of this code I'm calling the following method:

runInSystemShell(view, "latex " + file);

Now in examples like the above, the program (in this case "latex") returns a process or error level number when it finishes. If the program completes without errors, it returns 0. If it encounters an error it usually returns a non-zero process code. Is there a beanshell/Java command or Console method that will return this process code?? Unfortunately, the above method (runInSystemShell) doesn't return a value so I don't know what the process code is after it completes.

Any help appreciated. Thanks.
User login
Browse archives
« February 2018  
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
Yes, I'd like to have translations
No, that'd be bad (please comment)
Total votes: 1092
file   ver   dls
German Localization light   51081
Context Free Art (*.cfdg)   0.31   41260
JBuilder scheme   .001   17053
BBEdit scheme   1.0   16658
ColdFusion scheme   1.0   16636
R Edit Mode - extensive version   0.1   14919
Advanced HTML edit mode   1.0   14092
Matlab Edit Mode   1.0   14038
jEdit XP icons   1.0   13463
XP icons for jEdit   1.1   12487