The LaTeX editor I use, TeXStudio, allows for custom script-macros. I have little experience with JAVASCRIPT, but I do have one script I managed to create after reading the TeXstudio : user manual providing me with a list of JAVASCRIPT commands.
My example (primitive) script using only the commands in the user manual
%SCRIPT
txt = cursor.selectedText()
editor.write("{")
ln = cursor.lineNumber()
cn = cursor.columnNumber()
editor.write(txt+"}")
cursor.moveTo(ln,cn);
cursor.movePosition(1,cursorEnums.Left)
The above script presupposes the cursor selected some string. Then it surrounds it with "{" "}", and leaves the cursor in the desired location.
I am interested in a similar (inverse) script where the cursor is between $ $, and is able to select everything in between $ and $.
Much like how Ctrl+W selects an entire word, I want to create a script (which will be mapped to some shortcut) that selects an entire math environment between $ and $.