/* * This is simple jEdit macro replace to all occurences of space and an unit * with thin space entity and unit * * charset: UTF-8 * * (c) TAAT Digital Technologies 2006 * Tomasz Pęszor * info at taat dot pl * http://taat.pl/jedit/ */ void smart_units() { if (textArea.getSelectedText()==null) { mcp=textArea.getCaretPosition(); textArea.selectAll(); sn=true; } // define units to replace String[] search = {"Kb", "KB", "MB", "Mb", "GB", "Gb", "TB", "Tb", "m", "cm", "mm", "dm", "m3", "cm3", "cm3", "m2", "cm2", "dm2", "zł", "PLN", "$", "h", "km/h", "m/s", "g", "dkg", "kg", "s", "K", "rad", "sr", "MPH", "pH", "em", "ex", "px", "en", "t", "h", "W", "N", "dB", "A", "V", "Hz", "MHz", "GHz", "%", "$", "MW", "KM" }; String[] spaces = {" ", ".", ",", ";", "?", "!", ":"}; SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(false); SearchAndReplace.setAutoWrapAround(true); SearchAndReplace.setReverseSearch(false); for (int j=0; j"+sup[k]+""); SearchAndReplace.replace(view); } if (sn==true) { textArea.selectNone(); len=buffer.getLength(); if (mcp>len) mcp=len; textArea.setCaretPosition(mcp); } } // main if(buffer.isReadOnly()) Macros.error(view, "Buffer is read-only."); else smart_units(); /* Macro index entry (in DocBook XML) Smart_units.bsh This is simple jEdit macro replace to all occurences of space and an unit with thin space entity and unit (c) TAAT Digital Technologies 2008 */