From charlesreid1

To create LyX keyboard shortcuts, you use the bind file.

Process is covered at LyX#Customizing LyX and repeated here.


Determining where LyX Data Directory is

Open LyX, click LyX > About LyX, and look for the "User Directory". This is the directory where all data (bind files, UI files, layouts, etc.) should go.

Create a Bind File

The bind file, located at /Path/To/LyX/Data/Directory/bind, can be used to define or re-define keyboard shortcuts.

Some customizations that I have made in my LyX bind file are included below.

Install a Bind File

To actually install/use the bind file, you should create a new file like my_shortcuts.bind in the user data directory (see "Determining Where LyX Data Directory Is" above for how to find this directory).

Finally, open LyX and click LyX > Preferences. Open the Editing > Shortcuts preference panel. In the text box at the top, labeled Bind File, enter the name of the bind file without the .bind extension, e.g., my_shortcuts.

The shortcuts should be ready to go as soon as you save your preferences.


LyX 2.2.x

Just a few modifications - importing the mac bind file, and including some additional keyboard navigation shortcuts (these are also in mac.bind but whatevs).

# This is my own bind file.
# Charles Reid.

\bind_file mac.bind

# (cmd + , is show global lyx settings)
# cmd + shift + ,   show document settings
\bind "C-S-,"       "dialog-show document"


# Force LyX to exhibit normal mac behavior of
# alt + left = left 1 word
# alt + right = right 1 word
# (this is necessary because setting this in LyX > Preferences > Control > "Use Mac-style for cursor moving between words" doesn't work)
\bind "A-Right"                      "word-right"
\bind "S-A-Right"                    "word-right-select"
\bind "A-Left"                       "word-left"
\bind "S-A-Left"                     "word-left-select"
\bind "A-Up"                         "paragraph-up"
\bind "S-A-Up"                       "paragraph-up-select"
\bind "A-Down"                       "paragraph-down"
\bind "S-A-Down"                     "paragraph-down-select"


# ------------- straight from mac.bind ----------------

#  +: "Command-Right Arrow"          # Move the text insertion point to the end of the current line
\bind "C-Right"                      "line-end"
#  +: "Command-Left Arrow"           # Move the text insertion point to the beginning of the current line
\bind "C-Left"                       "line-begin"
#  +: "Command-Down Arrow"           # Move the text insertion point to the end of the document
\bind "C-Down"                       "buffer-end"
\bind "M-A-Down"                     "inset-end"
#  +: "Command-Up Arrow"             # Move the text insertion point to the beginning of the document
\bind "C-Up"                         "buffer-begin"
\bind "M-A-Up"                       "inset-begin"
#  +: "Shift-Command-Right Arrow"    # Select text between the insertion point and the end of the current line (*)
\bind "S-C-Right"                    "line-end-select"
#  +: "Shift-Command-Left Arrow"     # Select text between the insertion point and the beginning of the current line (*)
\bind "S-C-Left"                     "line-begin-select"
#  +: "Shift-Right Arrow"            # Extend text selection one character to the right (*)
\bind "S-Right"                      "char-right-select"
#  +: "Shift-Left Arrow"             # Extend text selection one character to the left (*)
\bind "S-Left"                       "char-left-select"
#  +: "Shift-Command-Up Arrow"       # Select text between the insertion point and the beginning of the document (*)
\bind "S-C-Up"                       "buffer-begin-select"
#  +: "Shift-Command-Down Arrow"     # Select text between the insertion point and the end of the document (*)
\bind "S-C-Down"                     "buffer-end-select"
#  +: "Shift-Up Arrow"               # Extend text selection to the line above, to the nearest character boundary at the same horizontal location (*)
\bind "S-Up"                         "up-select"
#  +: "Shift-Down Arrow"             # Extend text selection to the line below, to the nearest character boundary at the same horizontal location (*)
\bind "S-Down"                       "down-select"
#  +: "Shift-Option-Right Arrow"     # Extend text selection to the end of the current word, then to the end of the following word if pressed again (*)
\bind "A-Right"                      "word-right"
\bind "S-A-Right"                    "word-right-select"
#  +: "Shift-Option-Left Arrow"      # Extend text selection to the beginning of the current word, then to the beginning of the following word if pressed again (*)
\bind "A-Left"                       "word-left"
\bind "S-A-Left"                     "word-left-select"
#  +: "Shift-Option-Down Arrow"      # Extend text selection to the end of the current paragraph, then to the end of the following paragraph if pressed again (*)
\bind "A-Down"                       "paragraph-down"
\bind "S-A-Down"                     "paragraph-down-select"
\bind "S-M-A-Down"                   "inset-end-select"
#  +: "Shift-Option-Up Arrow"        # Extend text selection to the beginning of the current paragraph, then to the beginning of the following paragraph if pressed again (*)
\bind "A-Up"                         "paragraph-up"
\bind "S-A-Up"                       "paragraph-up-select"
\bind "S-M-A-Up"                     "inset-begin-select"

# ---------------------------------------------

# cmd + shift + M insert numbered formula
\bind "C-S-M"       "command-sequence math-display; math-number-toggle"

# cmd + shift + E = insert non-numbered formula
\bind "C-S-E"       "command-sequence math-display;"

# cmd + shift + n = nomenclature insert
\bind "C-S-N"       "nomencl-insert"

# cmd + shift + r = insert cross-reference
\bind "C-S-R"       "dialog-show-new-inset ref"

# cmd + shift + c = insert citation
\bind "C-S-C"       "dialog-show-new-inset citation"

# cmd + shift + L = insert label
\bind "C-S-L"       "label-insert"

# command-delete + r = delete row
\bind "C-Delete R"  "tabular-feature delete-row"

# command-delete + c = delete column
\bind "C-Delete C"  "tabular-feature delete-column"

# option-N = insert note
\bind "A-N"         "note-insert"

# option-C = insert comment
#\bind "M-S-C"         "comment-insert"


Problems with Bind File in LyX 2.2

When I installed the LyX 2.1 bind file into LyX 2.2 on a Mac, every Mac keyboard shortcut was broken. I had to explicitly add in the directive \bind_file mac.bind to include all the mac bind shortcuts into this bind file.

Problems with Bind File in LyX 2.0

When I initially switched to LyX 2.0, I ran into problems with my bind file and with all of my shortcuts no longer working. The reason was, in LyX 2.0, the bind files have changed "C" to mean "Command", "M" to mean "Control", and "A" to mean "Alt/Meta/Option".

This change seems illogical to me, but once you change all your "M"s to "A"s, everything should work as expected.


Flags