- Code: Select all
move to $_test
move
and I press TAB after the second move, that will align under the next text above it (to), for example:
- Code: Select all
move to $_test
move _ <- cursor gets placed here on 1 tab
Thanks!
Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.
move to $_test
move move to $_test
move _ <- cursor gets placed here on 1 tab





// This script inserts at current line spaces to align the next
// word on the next non whitespace character in the line above.
function SmartSpaces()
{
// Get current line number at caret position.
var nActLineNum = UltraEdit.activeDocument.currentLineNum;
// Do nothing if there is no line above.
if (nActLineNum < 2) return false;
// Get column number (with correction for UE < 16.00 and UES < 10.00).
var nActColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") nActColNum++;
// Move caret to the line above.
UltraEdit.activeDocument.key("UP ARROW");
// If the configuration setting "Allow positioning beyond line end" is
// enabled, the caret could be beyond line end. So move the caret to
// end of line and verify that the caret is now not left to initial
// column at script start which means the line above is shorter.
UltraEdit.activeDocument.key("END");
nNewColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") nNewColNum++;
if (nNewColNum < nActColNum)
{
// Restore caret position and do nothing if line above is shorter.
UltraEdit.activeDocument.gotoLine(nActLineNum,nActColNum);
return false;
}
// Move caret back to the right column in the line above.
UltraEdit.activeDocument.gotoLine(0,nActColNum);
// Find next space or tab character in this line.
while (!UltraEdit.activeDocument.isChar(' ') && !UltraEdit.activeDocument.isChar('\t'))
{
// Restore caret position and do nothing if end of line is reached.
if (UltraEdit.activeDocument.isChar('\r') || UltraEdit.activeDocument.isChar('\n'))
{
UltraEdit.activeDocument.gotoLine(nActLineNum,nActColNum);
return false;
}
UltraEdit.activeDocument.key("RIGHT ARROW");
}
// Find character which is not a space or tab in this line.
UltraEdit.activeDocument.key("CTRL+RIGHT ARROW");
// Restore caret position and do nothing if end of line is reached.
if (UltraEdit.activeDocument.isChar('\r') || UltraEdit.activeDocument.isChar('\n'))
{
UltraEdit.activeDocument.gotoLine(nActLineNum,nActColNum);
return false;
}
// Calculate the number of spaces to insert in the line below.
nNewColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") nNewColNum++;
var nSpaceCount = nNewColNum - nActColNum;
// Move caret back to initial position on script start.
UltraEdit.activeDocument.gotoLine(nActLineNum,nActColNum);
// Build the string to insert consisting only of spaces.
var sSpaces = "";
while (nSpaceCount--) sSpaces += ' ';
// It would be also possible insert tabs instead of spaces. But that
// is much more complicated as the script has to know the tab stop
// value for the current file and therefore how many spaces must be
// replaced by a tab character. And additionally it is necessary to
// determine how many spaces the first inserted tab represents in
// dependence of the column number at caret position.
// Determine if overstrike mode is active and if this
// is the case switch temporarily to the insert mode.
var bInsertMode = UltraEdit.insOvrMode;
if (!bInsertMode) UltraEdit.insertMode();
// Write the spaces into the file.
UltraEdit.activeDocument.write(sSpaces);
// Switch back to overstrike mode if active before insert.
if (!bInsertMode) UltraEdit.overStrikeMode();
return true;
}
if (UltraEdit.document.length > 0) // Is any file opened?
{
// If the active file is not opened in hex editing mode.
if (UltraEdit.activeDocument.hexMode == false)
{
if (!SmartSpaces())
{
// The function does nothing if it was not possible to determine
// how many spaces to insert. You can insert here whatever wanted
// to define the default behavior like inserting 3 spaces or 1 tab.
}
}
}