indiWiz.com

Subhash's Tech Log

Archive for the ‘jedit’ tag

JEdit Macro for XML/HTML Special Character Conversion

without comments

One of the common requirement I face often when posting text to blog/forum/Wiki etc. is character conversion:

& &
< &lt;
> &gt;
" &quot;
' &apos;

I developed a small JEdit Macro for doing this. This macro can be executed from JEdit menu Macros > Run Other Macro..., or can be installed by copying to: ${user.home}/.jedit/macros/ (later executed from the menu Macros). This macro operates on selected text.

Written by Subhash Chandran

December 31st, 2008 at 2:03 pm

Posted in Scripting

Tagged with

JEdit, powerful search and replace using BeanShell

with 2 comments

JEdit is my favorite text editor. And today I was pleased to find some powerful scripting capability in its search and replace functionality. Basically I wanted to enclose a RegularExpression pattern with:

<a href="">PATTERN</a>

The Search and Replace dialog provided an option Return value of a BeanShell snippet. So whatever RegularExpression pattern grouping I provided, I was able to access them using the BeanShell variable _1 to _9. So my final replace statement became:

"<a href\"\">" + _1 + "</a>"

Cool solution to a simple problem.

jedit_search_replace

Written by Subhash Chandran

December 17th, 2008 at 2:27 pm

Posted in OpenSource,Scripting

Tagged with