What is the fastest way to select next x number of lines?
I want to select x number of lines starting from the line that the cursor is on, or the first line of selected text frame if a text frame is selected.
I got together this very slow script that does the job, but there has to be a better way. My understanding of indesign scripting is very limited so I wanted to ask the elite.
I couldn't use textFrame.lines because i want to continue selecting lines from the next frame, also I couldn't use paragraphs.lines because the start may be in the middle of a paragraph.
var numLines = 5; // Change this to the number of lines you want to select
var selectedLine = app.selection[0].lines[0].index;
var firstChars = getFirstChars(numLines);
var start = selectedLine;
var end = firstChars[numLines - 1] - 1;
var secilecek = app.selection[0].insertionPoints[0].parent.characters.itemByRange(start, end);
secilecek.select();
function getFirstChars(numLines) {
var firstChars = [];
var nextLine = app.selection[0].lines[0].insertionPoints[-1].lines[0];
for (var i = 0; i < numLines; i++) {
nextLine.characters[0].select();
firstChars.push(nextLine.characters[0].index);
nextLine = app.selection[0].lines[0].insertionPoints[-1].lines[0];
}
return firstChars;
}
