GNU TeXmacsUser manualReferenceAboutEnglish·Français·中文
Structured editing

As a general rule, the behaviour of most structured editing operations is conditioned by the current focus. By default, the focus is on the innermost tag that contains the cursor. Whenever some selection is active, the focus is rather on the innermost tag that contains the selection. During structured operations, such as navigating among similar tags, the focus may temporarily be set to something else. The current focus is visually indicated by the innermost cyan box around the cursor.

For instance, the structured insertion commands ⌃←, ⌃→, ⌃↑ and ⌃↓ have a particular meaning both inside tables and trees. Inside tables, they allow you to insert new rows and columns (see figure ?). Inside trees, they correspond to the insertion of new nodes (see figure ?). If you are inside a tree inside a table, then the innermost tag is a tree, and node insertions will take precedence over the insertion of new rows and columns.

For most editing operations, a “default particular behaviour” has been defined. This behaviour may potentially be overridden for a few exceptional tags. In our example of structured insertion, the default behaviour of ⌃← and ⌃→ is to insert a new argument to the tag at the left or at the right of the cursor (when allowed). Inside tables, this behaviour is overridden so as to insert entire columns.

\(\displaystyle \left( \begin{array}{ccc} a & b {\color{red}{|}} & c\\ d & e & f \end{array} \right) \hspace{5em} \left( \begin{array}{cccc} a & b & {\color{red}{|}} & c\\ d & e & & f \end{array} \right) \qquad \left( \begin{array}{cccc} a & {\color{red}{|}} & b & c\\ d & & e & f \end{array} \right) \qquad \left( \begin{array}{ccc} a & b & c\\ & {\color{red}{|}} & \\ d & e & f \end{array} \right) \qquad \left( \begin{array}{ccc} & {\color{red}{|}} & \\ a & b & c\\ d & e & f \end{array} \right)\)

Figure 1. Assume that the cursor is at the position of | inside the left-most matrix. Then the four other matrices respectively correspond to the insertion of a new column at the left (⌃←) or right (⌃→), resp. a new row above (⌃↑) or below (⌃↓).

Figure 2. Assume that the cursor is at the position of | inside the left-most tree. Then the four other trees respectively correspond to the insertion of a new node at the left (⌃←), at the right (⌃→), above (⌃↑) or below (⌃↓).

Similarly, still in the case of matrices, the keys ⌃↖, ⌃↘, ⌃⇞ and ⌃⇟ can be used for inserting a new first or last column, resp. a new first or last row. The keys ⌥⌫ and ⌥⌦ are mapped to the commands for backward resp. forward structured deletion. For matrices, this will result in the removal of the column before or after the cursor (see figure ?). In order to remove the enclosing environment you may use ⌥⌫ or ⌥⌫.

\(\displaystyle \left( \begin{array}{ccc} a & b {\color{red}{|}} & c\\ d & e & f \end{array} \right) \hspace{5em} \left( \begin{array}{cc} b {\color{red}{|}} & c\\ e & f \end{array} \right) \qquad \left( \begin{array}{cc} a & {\color{red}{|}} c\\ d & f \end{array} \right) \qquad b {\color{red}{|}}\)

Figure 3. Assume that the cursor is at the position of | inside the left-most matrix. Then pressing the keys ⌥⌫ and ⌥⌦ respectively result in the next two matrices. Pressing either ⌥⌫ or ⌥⌫ replaces the matrix by the content of the cell in which you are, leaving you with the \(b\) at the right-hand side.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".