Anyways, I made a script for checking the text at the cursor to see if it matches any of my predefined texts (had an old macro for this before, but it's ways faster with JS).
ie, like this (cut down version, but it's basically it, only removed unimportant function definitions):
- Code: Select all
var word = UltraEdit.activeDocument.selectWord();
word = UltraEdit.activeDocument.selection;
var ColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") ColNum++;
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, ColNum); // reset selection
It just checks the text at the cursor and inputs the correct 'snippet' (template in this case) instead of the text. I invoke the script by pressing shift + space.
Now, here's the thing(s):
sometimes it seems the cursor position gets completely off, especially in conjunction with undo, results in selectWord to show contents I have no idea where it found (often chars with a value < 10 (00-0F) )
[$replace$] doesn't seem to work as it used to when inserting from JS (the indentation is completely ignored, which I think wasn't the case previously).
The first I solved with doing this before invoking selectWord();
The second problem I have no idea as to how to get around, anyone has any idea? (I have a version without templates where I fix the indentation right in the script, but it'd be tedious to do for all templates)