Alternative to arrow keys to exit from sub/superscripts

I am a heavy users of superscripts and subscripts.

After I use ^ to type the content of the superscript, I can exit from it by using the Right arrow key to move to the next variable. However, since in standard keyboards, the arrow key is on the right-hand side of the letter keys, it is a bit inconvenient to move between letter keys and arrow keys frequently. Hence, I wonder if there is any alternative way to exit from the sub/superscripts and move to the next variable without using arrow keys.

I think you have to kbd-map the command (kbd-right) to a key of your liking. Please let me know if this makes sense and if you need more instructions.

1 Like

You can also try something like

(kbd-map ("F1" (structured-exit-right)))

to use F1 to exit the current tag to the right. Most likely you want to use another keybinding, I’ve choosen F1 just as an example.

1 Like

(structured-exit-right), the right “tool for the job”. It will exit from the subscript from any position, I think, while (kbd-right) from the last position only.

Thank you very much! I use the following command to map it to the Space button (as in LyX)

(kbd-map 
  (:require (inside? 'equation*))
  ("space" (structured-exit-right)))

(kbd-map 
  (:require (inside? 'equation))
  ("space" (structured-exit-right)))

(kbd-map 
  (:require (inside? 'eqnarray*))
  ("space" (structured-exit-right)))

It works very well!

In addition, is there a list of all commands like structured-exit-right, so I can experiment with other features? It seems that math-kbd.scm itself does not contain structured-exit-right by default. For example, I’m thinking if it is possible to also use Space button to move the cursor from the end of the numerator to the beginning of the denominator of a fraction and to move the cursor to the right cell in a eqnarray, etc. I guess I also have to check if the cursor is inside a fraction or inside a cell of an eqnarray in order to do so, also check if a the cursor is in a super/subscript for the commands above.

3 Likes

You may check progs/generic/generic-edit.scm, progs/generic/generic-kbd.scm and doc/main/editing/man-structured-move.en.tm

Classifying all commands is probably a job for a contributor, although (I am guessing here) a part of commands is classified inside the manual.

1 Like

Note that maybe it is more efficient / conceptually clear to do

(kbd-map 
  (:require (or (inside? 'equation*) (inside? 'equation) (inside? 'eqnarray*)))
  ("space" (structured-exit-right)))

or define a suitable predicate and invoke it to determine if you are in an environment of a certain class for which you want structured movements.

2 Likes

The space key also has other functions in TeXmacs, including function application and multiplication. You may consider remapping the shortcut you’ve overridden to something else.

1 Like

For example ctrl+space

BTW I think not multiplication, but yes function application

Fair point. I use shift+space instead, better for my pinky figures XD.

Thank you. I’ll take a look.