When typing an equation in LyX math mode, pressing the space bar will sometimes exit the equation. This is annoying because I will often press it by accident. Sometimes I am typing fast and I immediately press backspace, which deletes my entire equation.

So my questions are:

  1. Is there a way to disable this space bar behaviour in LyX 2.2.1?
  2. Is there a way for the backspace key to delete the last symbol/element in the equation instead of the entire equation?

I have looked in "Preferences" but didn't find any relevant options. Perhaps there is an under-the-hood solution...?

EDIT: it looks like someone has tried something similar: http://www.math.ucdenver.edu/~hartkes/computer/lyx/lyx.php. Unfortunately, I'm having some trouble making heads or tails out of it.

EDIT: cross-posted at http://latex-community.org/forum/viewtopic.php?f=19&t=28474

  • I'm not completely sure, but I don't think there is a way to change the behavior as you would like. This is the first time I've seen this request for LyX. It does sound very frustrating though!
    – scottkosty
    Commented Sep 8, 2016 at 15:49
  • Considering @scottkosty's comment, barring messing about with the sourcecode and compiling LyX yourself, you likely don't have any other options than posting a feature request at lyx.org/trac/wiki/BugTrackerHome (For what it's worth, while I don't use LyX, I've actually been annoyed by the space bar exiting math mode myself, when making an example related to a question here on site.) Commented Sep 9, 2016 at 7:18

1 Answer 1


There is no way in LyX to do what you want so we need to edit the source code and recompile. Here is a patch that makes it so space does not exit math:

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 3460cdc..9c102dc 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -921,14 +921,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
        // spacial handling of space. If we insert an inset
        // via macro mode, we want to put the cursor inside it
        // if relevant. Think typing "\frac<space>".
-       if (cmd.argument()[0] == ' '
-           && cur.inMacroMode() && cur.macroName() != "\\"
-           && cur.macroModeClose() && cur.pos() > 0) {
-           MathAtom const atom = cur.prevAtom();
-           if (atom->asNestInset() && atom->isActive()) {
-               cur.posBackward();
-               cur.pushBackward(*cur.nextInset());
-           }
+       if (cmd.argument()[0] == ' ') {
+           // do nothing
        } else if (!interpretChar(cur, cmd.argument()[0])) {
            cmd = FuncRequest(LFUN_FINISHED_FORWARD);

If you happen to be on Ubuntu (or other Linux), compiling LyX is easy and I can help you. If you are on Windows or Mac it is possible but much more complicated.

Disclaimer: this patch probably breaks something, but it worked for me in limited testing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .