Actually it could be done using a simple script like this one (experimental
version - bug reports/comments welcome ...)
The another function splits text in separate lines using the given separator
(regular expression metacharacters need to be escaped with backslash "\" )

If someone would be interested in testing it, you can simply save it e.g. to 
???\PSPad\Script\JScript\join.js

recompile scripts and run it from the script menu

Since it is a pretty simple javascript, there might be some performance issues
on larger files, 
so I don't think, it would be worth adding on a extensions page...


////////////////////////////////////////

var module_name = "join_split_js";
var module_ver = "1";


function joinLines(){ 
// joins lines (in selection or in the whole document) using the given separator
- default: space; 
// pressing Esc, clicking Cancel, or deleting the default space and clicking OK
sets separator 
// to an empty string; once executed, can be undone via Ctrl+Z (Undo) only
var actEd = newEditor();
actEd.assignActiveEditor();
var separJoin = InputText("Enter separator (joining):"," "); 
var joinRE =  new RegExp("(\r|\n|
){2}","g");
if (actEd.selText().length > 0){
var inputTxt = actEd.selText();
var outputText = inputTxt.replace(joinRE, separJoin);
actEd.selText(outputText);
}else{
var inputTxt = actEd.text();
var outputText = inputTxt.replace(joinRE, separJoin);
actEd.text(outputText);
}
}

function splitLines(){
//splits lines (in selection or in the whole document) using the given separator
- Regular Expression - 
// default: space; pressing Esc, clicking Cancel, or deleting the default space
and clicking OK 
// sets separator to an empty string, i.e.: splits each character to a separate
line; 
// once executed, can be undone via Ctrl+Z (Undo) only 
var actEd = newEditor();
actEd.assignActiveEditor();
var separSplit = InputText("Enter separator - RE - (splitting):"," ");
var SplitRE = new RegExp(separSplit,"g");
if (actEd.selText().length > 0){
var inputTxt = actEd.selText();
var outputText = inputTxt.replace(SplitRE, "\n");
actEd.selText(outputText);
}else{
var inputTxt = actEd.text();
var outputText = inputTxt.replace(SplitRE, "\n")
actEd.text(outputText);
}
}

function Init(){
addMenuItem("Join lines", "", "joinLines","Ctrl+Alt+J");
addMenuItem("Split lines", "", "splitLines","Ctrl+Alt+S");
}

////////////////////////////////////////////////

-- 
<http://forum.pspad.com/read.php?2,39067,39095>
PSPad freeware editor http://www.pspad.com

Odpovedet emailem