Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

KeyboardShortcuts

Categories: Keyboard, Customization
<< | Page list | >>

Modifying LyX keyboard shortcuts

This page contains some tips for modifying your keyboard bindings in LyX.

Before modifying, have a look at the KeyboardShortcuts#StandardKeybindings in LyX.KeyboardShortcuts. Maybe one of the standard files is already (close to) what you want. (See also frequently used shortcuts)

There are some blocked keyboard shortcuts that require special attention.

Besides simple LyxFunctions, you can also bind command sequences to a key. Use this to create your keyboard macros.

Remember to read the section in Customization.lyx and Appendix A -- Bindings in the Customization.lyx document (Help>Customization or excerpt below).

A practical tip

Instead of modifying any of the standard bind-files, create a new bind-file, say $HOME/.lyx/bind/myShortcuts.bind and include one of the standard files, e.g.:

# include one of the basic flavours (cua or emacs)
\bind_file	"cua"
# add your own bindings (overwriting the included ones)
\bind		"C-b" "font-bold"

Then go to the preferences dialog and choose this file to be your bind-file.

Syntax of the .bind-files

The syntax of the .bind files is straightforward:

\bind <key combination> <lyx-function> # bind a key to a function
\bind_file "bindfile-name" # include another bind file
  • The included bind file is named without the ".bind" extension
  • Both key combination and lyx-function (including any arguments) must be enclosed in "double quotes".
  • The syntax of the <key-combination> is [<Modifier>-[<Modifier>-[<Modifier>-]...]]<Key> where the order of the modfiers doesn't seem to matter.
  • To insert TeX code, you may need to use double backslashes. For example "math-insert \to" doesn't work, but "math-insert \\to" does.

Key modifiers

This is a (possibly incomplete) list of table modifiers:

ModifierMeaning
CControl
MMeta, i.e. typically Alt on PC-keyboards
SShift
~S"the state of the shift key is not relevant" (this is useful because "2", for example, will need shift on a french keyboard, but not on an US one).

Equivalent keys

Testing revealed that the keys <a> and <A> are equivalent in some combinations, i.e.:

  • "C-a" is equivalent to "C-A"
  • "C-S-a" is equivalent to "C-S-A"

Precedence of keyboard bindings

Note that the latest key binding takes precedence, e.g.

   \bind "C-b" "font-emph"              
   \bind "C-b" "font-bold"    

will bind "C-b" to "font-bold", since that is the last key binding command. An exception are bindings using the modifier "~S", which doesnot overide other bindings. E.g.

   \bind "C-~S-a" "self-insert a"    

means that both "C-a" and "C-S-a" will insert a 'a'. However, with these bind commands:

 \bind "C-a" "self-insert a"  
 \bind "C-S-A" "self-insert A" 
 \bind "C-~S-a" "self-insert b"

You end up with these key mappings:

Key combinationInserts
"C-a"a
"C-S-aA

but you will never get 'b', i.e. the binding "C-~S-a" is never activated.
If the first bindings is removed, i.e. with only these bindings

 \bind "C-S-A" "self-insert A"  
 \bind "C-~S-a" "self-insert b"

then you get these key mappings:

Key combinationInserts
"C-a"b
"C-S-a"A

Excerpt from "Customization.lyx", section 3.3. Bindings

Below is a simple copy of section 3.3. in Customization.lyx, i.e. the section about bindings.

Bindings
Bindings are used to, well, bind a function to a key. Several prepackaged binding files are available: a CUA set of bindings (familiar as the typical set of PC and CDE set of keyboard shortcuts), an Emacs set of bindings, for those of us who follow the One True Way and refuse to lower our standards,I'm kidding here, of course! as well as specialty bindings (broadway and hollywood) and other languages (French, German, etc.).
If, however, you'd like to customise the keybindings to your own exacting tastes, then copy the best-fit file in LyXDir/bind/ to your own UserDir/bind/ and modify that. Don't forget to load this new file into LyX using the Preferences dialog. (For the moment you'll have to restart LyX for these changes to take effect.)
LyX supports internationalization of the user interface (see Chapter [chap:i18n]). If your locale is set, with the environment variable $LANG, LyX will try to use bindfiles by prepending $LANG_ to their name. For example, you can put a translated copy of some standard bind file in your personal bind/ directory, and LyX will use it automatically. [Author's Note: Not sure if this is true anymore. Perhaps someone who uses such a thing could test. --- AL]
The syntax of the .bind files is straightforward:
\bind <key combination> <lyx-function>
Both key combination and lyx-function (including any arguments) must be enclosed in "double quotes". All the LyX functions are listed in the Reference Guide.

List of key names

This table lists some of key names that you can use in .bind-files. (See latinkeys-bind for some more odd keys)

KeyDescriptionBind example or comment
a-z, A-Z, 0-9Alphanumeric keys 
F1-F12Function keys\bind "F3" "file-open"
Left, Right, Up, DownCursor keys 
Home, End, Insert, Delete  
less, greater< and > 
equal= 
minus, plus- and +\bind "C-minus" "hyphenation-point-insert"
underscore_ 
space \bind "C-space" "protected-space-insert"
BackSpace \bind "C-BackSpace" "word-delete-backward"
ReturnEnter key\bind "C-Return" "break-line"
Escape \bind "Escape" "cancel"
apostrophe \bind "M-i apostrophe" "quote-insert"
quotedbl"\bind "~S-C-quotedbl" "self-insert \""
quoteleft, quoteright??? 
at, dollar@ and $ 
numbersign# 
asterisk* (US keyb?) 
exclam, exclamdown! and ¡ (Spanish keyb.?) 
percent% 
ampersand& 
slash/ 
parenleft, parenright( and ) 
bracketleft, bracketright[ and ] 
braceleft, braceright{ and } 
colon, semicolon: and ; 
period, comma. and ,\bind "C-period" "end-of-sentence-period-insert"
questionThe ? key 
nobreakspaceIs this a real key? 
yen, currency??? 
cent, sterling??? 
copyright©S-AltGr-C (Linux), Option-C (Mac)
registered®S-AltGr-R (Linux), Option-R (Mac)
brokenbarlike |, but broken? 
aring, Aringå and Å 
onehalf½ 
ordfeminine??? 
masculine??? 
?§ ('section' ?) 
adiaeresisä 
odiaeresisö 
?\ 
?¿ (Spanish keyb.) 

The keypad:

?KP_DivideKP_MultiplyKP_Subtract
KP_7, KP_HomeKP_8, KP_UpKP_9, KP_PriorKP_Add
KP_4, KP_LeftKP_5KP_6, KP_RightKP_Add
KP_1, KP_EndKP_2, KP_DownKP_3, KP_Next?KP_Return?
KP_0, KP_InsertKP_0, KP_InsertKP_Decimal?KP_Return?

Keyboard Customization

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2022-05-26 08:11 UTC