Macro phrase selection and line selection for texstudio

Texstudio is the best editor for latex, but it lacks some features that will improve productivity. One of the features that might be of interest to many is selecting several words and lines. This is due to fact that many copy and pastes are needed in a good latex document.

In this regard, I'm looking for a macro which:

1. Selects the current word in the first call.

2. Adds the successive words in each call afterward.

The same macro for the line operation is also desired:

1. Selects the current line in the first call

2. Adds the following lines in successive words in the calls afterward.

Consider the following example:

\begin{dmath}\label{key}
\min \zeta\\
|w_k^+ - w_k^-|+|z_k^{+} - z_k^{-}| \le \zeta\\
w_k = x_{R} - \Re\{\mu_k\}\\
z_k = x_{I} - \Im\{\mu_k\} \\
w_k = w_k^+ - w_k^- \\
z_k = z_k^{+} - z_k^{-}\\
w_k^+ \ge 0,  w_k^- \ge 0,\\
z_k^{+}\ge 0,  z_k^- \ge 0,
\end{dmath}


In the first case, I need to select part of a line and copy and paste it. For instance:

z_k^{+} - z_k^{-}


In the second case, I need to select several lines and copy and paste it. For instance:

   w_k = w_k^+ - w_k^- \\
z_k = z_k^{+} - z_k^{-}\\


I want such a functionality to be done through the keyboard (minimum usage), without using the mouse. In this regard, if there would be a macro I can assign a shortcut to it and use the functionality.

• It seems that second functionality is already there. In Edit> selection> expand selection to line – Hamid Nov 1 '17 at 10:25

Selecting Lines

Edit -> Selection -> Expand Selection to Line

Selecting Words

There is Edit -> Selection -> Expand Selection to Word. However this has another scope: It consecutively selects all the occurences of the word under the cursor.

You can write your desired functionality yourself in a user macro. Here is a starting point. Maybe you'll need some adaptions to control the exact behavior.

%SCRIPT
if (!cursor.hasSelection()) {
cursor.select(cursorEnums.WordUnderCursor)
} else {
cursor.movePosition(1, cursorEnums.NextWord, cursorEnums.KeepAnchor)
}


For more details on scripting see the User Manual and the Wiki.

• That would be great if the reverse of this operations also was present. That is, in each keypress one word or one line is deselected – Hamid Nov 2 '17 at 16:08
• Just make a second script with cursorEnums.PreviousWord. – Tim Hoffmann Nov 2 '17 at 21:16
• what about line? – Hamid Nov 3 '17 at 19:06
• cursorEnums.PreviousLine – Tim Hoffmann Nov 4 '17 at 7:07