Highlighting Expressions

When commands are applied to terms in expressions, the highlighted expression determines what the command actually does. What term is highlighted is controlled by either using the arrow keys or mouse clicks. Mouse click and drag can also be used to move one or more expressions in a Document module.

Highlighting Using the Arrow Keys

The up, down, left, and right arrows move the highlight in the expression tree. Up and down arrows increase or decrease the highlight. The left and right arrows move between entries within a branch of the expression or from branch to branch, depending on what is highlighted.

The Shift + Left Arrow and Shift + Right Arrow keystroke combinations highlight more than one term in objects that are associative (monoids). See the section below on Shift + Arrow Highlighting.

Highlighting Using the Mouse

To highlight a term in an expression with the mouse, you need to click on an element of that term. But the highlighting process will highlight smallest term it can that contains the location of the mouse click, So in the expression

(x + y)/2

clicking on the "x" or the "y" will only highlight either "x" or "y", not x + y. The easiest way to highlight x + y with the mouse is to click on the "+" symbol. This is true for pretty much all objects. To highlight a particular term in an expression using the mouse, look for the symbols that are part of that term and click on any of those symbols. Another example would be the Sqrt object - here clicking on any part of the square root symbol highlights that entire term, independent of the complexity of the term inside of the square root.

In a Document module, you can highlight multiple expressions by dragging with the mouse, click outside the expressions and drag your cursor over the expressions. You can use this method to highlight one or more expressions. When the expression or expressions are highlighted, click anywhere within the highlight to drag the highlighted area to another part of your document.

You can also use this method of highlighting to cut, copy, and paste.

Keystroke Highlighting action
Up Arrow Moves the highlight to the parent of the currently highlighted term. Does nothing if there is no parent.
Down Arrow Moves the highlight to the first child of the currently highlighted term. So if the highlight is f[a, b] or a + b, the highlight would move to "a" in both cases. If there are no child terms and if the expression can be put in edit mode, then the down arrow toggles the edit mode.
Left Arrow Moves the highlight to the previous sibling term. So if the expression is a + b + c + d and the highlight is on "b", then left arrow moves the highlight to "a". Using left arrow again moves the highlight to "d", so the left and right arrows "wrap" the highlight to the other end of the list of sibling terms.
Right Arrow Moves the highlight to the next sibling term. So if the expression is a + b + c + d and the highlight is on "c", then right arrow moves the highlight to "d". Using right arrow again moves the highlight to "a", so the left and right arrows "wrap" the highlight to the other end of the list of sibling terms.
Shift + Left Arrow See notes below
Shift + Right Arrow See notes below
Shift + Up Arrow Highlights the entire expression when the highlight is on any sub-expression.

Shift + Arrow Highlighting

Only acts on objects that are monoids (roughly speaking, objects that are associative). Examples include addition, multiplication, the At object and several of the list objects. If a child term of any of these objects is highlighted, then Shift + Left or Shift + Right arrow will also highlight the previous or next sibling, respectively.

If the expression is a + b + c + d, and "b" is highlighted, then Shift + Right arrow results in b + c being highlighted. What is happening here is that we are actually converting the original expression, Add[a, b, c, d] into Add[a, Add[b, c], d] and then just highlighting the single child term Add[b, c] in the top Add object.

Now if you apply a command to the highlight, the term Add[b, c] is passed into the command function and the result expression (if any) from the command is used to replace Add[b, c] in the top level Add expression.

If the highlight is just removed from the Add[b, c] term, or moved to another term, then the Add object is "flattened" back to its original form.