Home | Download | Help | Contribute | Plug-ins | About | Contact | Search
Editing tools
Manual | Top | Previous | Next

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 x in math mode, you will only find matches which are also in math mode.

1.Cut and paste

You can select text and formulas by maintaining the left mouse button. In order to delete the selected region, use EditCut. In order to copy the selected region, first click on EditCopy. Next, paste it as many times as you want to the location of your cursor, using EditPaste. Alternatively, you may copy a selected region using the middle mouse button.

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 TextColorRed. Similarly, if you select a formula and you click on InsertMathematicsFraction, then the formula becomes the numerator of some fraction.

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 EditImport resp. EditExport. By default, copying and pasting uses the primary text buffer. Using EditCopy to and EditPaste from, you may specify as many other buffers as you like.

There are two ways to make selections using the keyboard. When using the cursor keys left, right, etc. while holding down the shift button, you may select text while moving around the cursor. Alternatively, you may press C-space 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 C-g.

Notice that the C-space shortcut also allows you to make structured selections. You may select the current word you are in by pressing C-space twice. Each additional time you press C-space results in the selection of the smallest structure which englobes the current selection. Ultimately, when the entire document gets selected, pressing C-space once more clears the selection.

2.Search and replace

You can start searching text by pressing C-s or EditSearch. During a search, the “search string” is displayed at the left hand side of the footer. Each character you type is appended to this search string and the next occurrence of it is surrounded by a red box. When pressing C-s a second time during a search, the next occurrence is being searched. A beep indicates that no more occurrences were found in the document; pressing C-s will continue the search at the beginning of your document. You may press backspace in order to undo key presses during a search.

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 x 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 EditReplace. You are prompted for a string which is to be replaced and the string by which to replace. At each occurrence of the string to be replaced you are prompted and you have to choose between replacing the string (y), not replacing it (n) and replace this and all further occurrences (a). Like in the case of searching, the query-replace command is mode and language sensitive.

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 EditCopy toSearch. Next hit C-s twice or more in order to search all occurences of this fragment inside your document. Similarly, using EditCopy toReplace, you may select a second fragment by which you want to replace the first one. In order to start the replacement, hit C-= and specify the empty string as the arguments for “Replace” and “Replace by”.

3.Spell checking

If the program ispell has been installed on your system, then you may use it to check your text for misspelled words by pressing M-$ or EditSpell. Notice that you might have to verify that the dictionaries corresponding to the languages in which your texts have been written have been installed on your system; this is usually the case for English.

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:

a)
Accepts the misspelled word and all its future occurrences in the text.
r)
Replace the misspelled word by a correction you have to enter.
i)
Indicate that the “misspelled” word is actually correct and that it has to be inserted in your personal dictionary.
1-9)
Several suggested corrections for your misspelled word.

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.

4.Undo and redo

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 EditUndo or using the keystrokes M-[ or C-/. Undone changes can be “redone” using EditRedo or M-].

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 HelpScheme). When specifying a negative number as your maximal undo depth, any number of actions can be undone.

5.Structured editing

As a general rule, the behaviour of most structured editing operations is conditioned by the innermost tag for which a particular behaviour has been defined.

For instance, the structured insertion commands A-left, A-right, A-up and A-down 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 A-left and A-right is to insert a new argument to the tag at the left or at the right (when allowed).

(
a b| c
d e f
) (
a b | c
d e f
) (
a | b c
d e f
) (
a b c
|
d e f
) (
|
a b c
d e f
)

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 (A-left) or right (A-right), resp. a new row above (A-up) or below (A-down).

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 (A-left), at the right (A-right), above (A-up) or below (A-down).

Similarly, in the case of matrices, the keys A-home, A-end, A-pageup and A-pagedown can be used for inserting a new first or last column, resp. a new first or last row. The keys A-backspace and A-delete 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 C-backspace or C-delete.

(
a b| c
d e f
) (
b| c
e f
) (
a |c
d f
) b |

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

6.Structured cursor movement

TeXmacs implements the three main mechanisms for structured cursor movement:

  1. Traversal of the entire structure of the document.
  2. Traversal of tags which are similar to the innermost tag.
  3. Movements inside the innermost tag.

Most keyboard shortcuts for structured cursor movements can be used in combination with the shift-key so as to similtaneously select text while moving around.

To do: customizing the behaviour

Structured traversal of the document

The C-left, C-right, C-up and C-down keys are used for the structured traversal of the entire document. Inside plain text, C-left and C-right allow you to move in a word-by-word manner, while C-up and C-down correspond to paragraph-by-paragraph motion.

In the presence of other markup, the C-left and C-right 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 C-up and C-down keys is more context-dependent. Inside matrices, they typically allow you to move one row up or down.

Traversal of tags which are similar to the innermost tag

This type of cursor movement allows you to quickly visit all other tags in the document which are similar to the innermost tag. The C-pageup and C-pagedown keys allow you move to the previous or next similar tags, whereas C-home and C-end 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 C-pageup. Notice that you may use C-§ to jump to the previous section title.

Movements inside the innermost tag

It is also possible to quickly move inside the innermost tag without quitting it, using H-left, H-right, etc. We recall that the H- prefix corresponds to the hyper-key, which does not exist on most keyboards. In order to compose H--based shortcuts, you may either configure your keyboard so as to map another key to H-, or simulate the hyper key using escape escape escape or C-escape.

In general, H-left, H-right, H-home and H-end provide a way to move to the previous, next, first or last argument of the innermost tag. Furthermore, the shortcuts H-( and H-) 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 H-up, H-down, H-pageup and H-pagedown.

7.Structured variants

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 C-tab and C-S-tab 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 C-tab several times will change the theorem into a proposition, a lemma, a corollary, a conjecture and back into a theorem. The C-S-tab key allows you to cycle in the inverse direction: theorem → conjectur → corollary → lemma → proposition → theorem.

In the case of mathematical formulas, the C-tab shortcuts allows you to change an inline formula like a2 + b2 = c2 into a displayed formula like

a2 + b2 = c2

while taking care of potential “trailing spaces and punctuation signs”.

TeXmacs also provides the A-* 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 A-* also turns an unnumbered itemize environment into an enumeration and vice versa, whereas C-tab allows you to cycle between the available kinds of list items (bullets, dashes, arrows, etc.).

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".