/* * Remove_blank_lines.bsh * a BeanShell macro for jEdit * by Tomek Pęszor * tomek at taat dot pl * * version 1.0 * charset: UTF-8 * * This simple macro removes blank lines from the current buffer or selection (lines with spaces or tabs also, not only \n\n) * It just uses simple RegEx: ([\t\s]+)?\n+\n? * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the jEdit program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ lineSeparator="\\n"; SearchAndReplace.setSearchString("([\\t\\s]+)?("+lineSeparator+")+("+lineSeparator+")?"); SearchAndReplace.setReplaceString(lineSeparator); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(false); SearchAndReplace.setRegexp(true); if (textArea.getSelectedText()!=null){ SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replace(view); } else SearchAndReplace.replaceAll(view); /* Macro index data (in DocBook format) Remove_blank_lines.bsh This simple macro removes blank lines from the current buffer or selection (even indented with spaces or tabs) It just uses simple RegEx: ([\t\s]+)?\n+\n? */