![]() |
Editing tools | ![]() |
In this chapter, we discuss the general editing facilities present in
TeXmacs. Besides classical features, like “cut and paste”,
“search and replace”, etc., TeXmacs also
supports additional functionality which exploits the document
structure. Examples of such features are “structured cursor
movement” and “structured variants”. It should be
noticed that more traditional functions like “search and
replace” also attempt to exploit the structure. For instance,
when searching
in math mode, you will only
find matches which are also in math mode.
You can select text and formulas by maintaining the left mouse button.
In order to delete the selected region, use 


It is also possible to the change text properties of a selected
region. For instance, in order to transform some black text in red,
you select it using the left mouse button and click on 


When using the copy and paste mechanism to communicate with other
applications, text is copied and pasted using the TeXmacs data format.
You may specify other import and export formats using 



There are two ways to make selections using the keyboard. When using the cursor keys left, right, etc. while holding down the button, you may select text while moving around the cursor. Alternatively, you may press once to fix a starting position. When moving around using the cursor keys, the text between the starting position and the current position keeps being selected. The selection gets cleared when pressing .
Notice that the shortcut also allows you to make structured selections. You may select the current word you are in by pressing twice. Each additional time you press results in the selection of the smallest structure which englobes the current selection. Ultimately, when the entire document gets selected, pressing once more clears the selection.
You can start searching text by pressing C-s or 
Usually, text is being searched for in a forward manner, starting from
the current cursor position. You may also search backwards, using
C-r. During a search, only text in the same mode and
the same language will be found, as those which are active at the
position where you started your search. In other words, when searching
an
in math-mode, you will not find any x's in
the ordinary text. As a current limitation, the search string can only
contain ordinary text and no math-symbols or more complicated
structured text.
A query replace is started by pressing C-= or 
The current search and replace system is still quite rudimentary in the sense that it only deals with plain text in a simple way. In the future, we plan to implement a more powerful search and replace mechanism for structured text.
For the time being, you may nevertheless search and replace arbitrary
document fragments as follows: somewhere inside your document or
another window, select the fragment you want to search using 



If the program ispell has been installed on your
system, then you may use it to check your text for misspelled words by
pressing or 
When you launch the spell checker (either on the whole text or a selected region), you will be prompted at each misspelled word and the footer displays the available options:
Notice that ispell just checks for misspelled words. No grammatical faults will be detected.
When starting the spell checker, it will use the dictionary of the language which is active at the current cursor position (or the start of a selection). Only text in that language will be checked for. If your document contains text in several languages, then you will have to launch the spell checker once for each language being used.
It is possible to gradually undo the changes you made in a document
from the moment that you launched TeXmacs. This can be done via 

In order to save memory, the number of successive actions which can be undone is limited to 100 (by default). It is possible to increase this number by adding a command like
(set-maximal-undo-depth 1000)
in our personal initialization file (see 
As a general rule, the behaviour of most structured editing operations is conditioned by the current focus. By default, the innermost tag which contains the cursor. Whenever some selection is active, the current focus is the innermost tag which contains the selection. During structured operations, such as navigating among similar tags, the current 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 ?). Whenever you 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.
In many cases, a “default particular behaviour” has been defined for all tags minus some exceptional ones. 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 (when allowed).
Similarly, 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. In the case of 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 .
TeXmacs implements the three main mechanisms for structured cursor movement:
Most keyboard shortcuts for structured cursor movements can be used in combination with the -key so as to similtaneously select text while moving around.
| To do: customizing the behaviour |
The , , and keys are used for the structured traversal of the entire document. Inside plain text, and allow you to move in a word-by-word manner, while and correspond to paragraph-by-paragraph motion.
In the presence of other markup, the and keys allow you to visit all accessible cursor positions of the document, except that we keep moving in a word-by-word manner inside plain text. The behaviour of the and keys is more context-dependent. Inside matrices, they typically allow you to move one row up or down.
This type of cursor movement allows you to quickly visit all other tags in the document which are similar to the innermost tag. The and keys allow you move to the previous or next similar tags, whereas and directly jump to the first or last similar tags.
For instance, when you are inside a section title, you may move to the previous sectional title (which could also be the title of a subsection or a chapter, for instance) using . Notice that you may use C-§ to jump to the previous section title.
It is also possible to quickly move inside the innermost tag without quitting it. The shortcuts , , and provide a way to move to the previous, next, first or last argument of the innermost tag. Furthermore, the shortcuts and may be used to exit the innermost tag on the left or on the right.
This default behaviour may be overridden in special contexts. For instance, inside tables or trees, they rather correspond to cell-by-cell or node-by-node cursor movement. In addition, these cases associate vertical cursor movements to , , and .
When creating an environment like a theorem, an equation or a list, it frequently happens that one would like to change the environment a posteriori. This can be done using the keyboard shortcuts and for cycling through the list of structured variants of the innermost tag in a direct or inverse manner.
For instance, assuming that you are inside a theorem, pressing several times will change the theorem into a
proposition, a lemma, a corollary, a conjecture and back into a
theorem. The key allows you to cycle in
the inverse direction: theorem
conjectur
corollary
lemma
proposition
theorem.
In the case of mathematical formulas, the
shortcuts allows you to change an inline formula like
into a displayed formula like
while taking care of potential “trailing spaces and punctuation signs”.
TeXmacs also provides the shortcut for turning numbered environments into unnumbered environments and vice versa. This works for most common environments like theorems, remarks, tables, equations, etc. Notice that also turns an unnumbered itemize environment into an enumeration and vice versa, whereas allows you to cycle between the available kinds of list items (bullets, dashes, arrows, etc.).
The prefix may be used for positioning
and resizing objects. For instance, inside a cell of a table, you may
use structured:geometry right to align the cell more
to the right. Behind a space introduced via 
Particular tags to which the shortcuts apply are the following


When writing documents in collaboration with other authors, it
frequently arises that one wants to go through changes made by the
other authors, and either accept, discard or further correct them.
After enabling the versioning tool through 


For the moment, automatic version control systems such as
Assume that we have two versions old.tm and new.tm
of the same document. In order to see the changes, first load the
newest version new.tm, then click on 

It is possible to go through all the differences between the old and
new versions either from the items in the submenu 
Differences between the two versions can be displayed in three ways: by showing only the old version, only the new version, or both versions simultaneously. In all cases, the old version is displayed in dark red and the new version in dark green.
The visualization style can be specified individually for each
individual change, via 






It often occurs that we want to go through the changes between two
versions and progressively retain either one or the other version for
each individual difference. Assuming that the cursor is inside a given
difference, this can be done from entries in the submenu 
It is also possible to globally select the old, new or current version
using 







The entries in the submenu 
The grain is used when comparing two documents using 


Similarly, the cursor is inside a difference, then you may recompare
the two versions 
