// Non-matching words var excludeWords = ["a","an","and","for","or","as","at", "of"]; /* Choose between: eeCaseLowerCase eeCaseUpperCase eeCaseCapitalize */ var convertTo = eeCaseCapitalize; function coords() { return { x: document.selection.GetActivePointX(eePosLogical), y: document.selection.GetActivePointY(eePosLogical) }; } function contains(arr,str) { for (var i = 0; i < arr.length; i++) { if (arr[i] == str) return true; } return false; } var matchNonwhitespace = new RegExp("\\S"); var left = { x: document.selection.GetTopPointX(eePosLogical), y: document.selection.GetTopPointY(eePosLogical) }; var selected = { x: document.selection.GetBottomPointX(eePosLogical), y: document.selection.GetBottomPointY(eePosLogical) }; if (left.x > 1) { document.selection.SetActivePoint(eePosLogical, left.x, left.y); document.selection.SetActivePoint(eePosLogical, left.x-1, left.y, true); if (document.selection.Text != " ") { document.selection.WordRight(); left = coords(); } } while (left.y < selected.y || left.x < selected.x) { document.selection.SetActivePoint(eePosLogical, left.x, left.y); document.selection.WordRight(true); var right = coords(); if (matchNonwhitespace.test(document.selection.Text)) { if (document.selection.Text.slice(-1) == " ") { right = coords(); document.selection.SetActivePoint(eePosLogical, left.x,left.y); document.selection.SetActivePoint(eePosLogical, right.x-1,right.y,true); } if (!contains(excludeWords, document.selection.Text)) document.selection.ChangeCase( convertTo ); } left = right; }