plisskin:
--------------------------------------------------------------------------------
At my old job we used TextPad as a text editor and it had a really nice feature
where the cursor would move to the same 'x' position when you moved up or down a
line.
...
Does anyone know what this feature is called and if PSPad supports it?
--------------------------------------------------------------------------------
Hi, I recently needed a similar cursor behaviour for editing some uniform data;
it turned out, that a simple script can help with that:
///////// caretMove.js ///////////////////////
var module_name = "caretMove";
var module_ver = "1";
var savedCaretXPos = 0;
function storeCaretX(){
if (editorsCount()<1){return;}
var actEd = newEditor();
actEd.assignActiveEditor();
savedCaretXPos = actEd.caretX();
}
function lineUpCaretX(){ moveCaretVert(-1);}
function lineDownCaretX(){ moveCaretVert(1);}
function moveCaretVert(vertDistance){
if (editorsCount()<1){return;}
var actEd = newEditor();
actEd.assignActiveEditor();
actEd.setCaretPos(savedCaretXPos, actEd.caretY()+vertDistance);
}
function Init(){
addMenuItem("Remember CaretX", "Caret move", "storeCaretX","Ctrl+Shift+C");
addMenuItem("line up CaretX", "Caret move", "lineUpCaretX","Alt+Up");
addMenuItem("line down CaretX", "Caret move", "lineDownCaretX","Alt+Down");
}
////////////////////////////////
Save the code between slashes as e.g.
...\PSPad\Script\JScript\caretMove.js
Call: Scripts: Reload scripts
(the WSH scripting support of PSPad must be active.)
I find this behaviour quite predictable, since you have to store the wanted
column at the beginning (call Remember CaretX with the caret at the right
position)
Moving up or down then tries to respect this column (if possible in the given
line).
The problem, which isn't dealt with, is accidentaly using this functions without
storing the needed column - in that case the previous setting is used (possibly
for another document) or the default 0.
hth,
vbr
--
<http://forum.pspad.com/read.php?2,47649,48027>
PSPad freeware editor http://www.pspad.com