Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

KeyboardShortcutForCharacterStyles

<< | Page list | >>

How to define a keyboard shortcut to work better with character styles.

1.  From a post by Steve Litt

This is from a post by Steve on the users' lists.


Hi all,

1.5x might have made it easier, but 1.4x requires you to do the following in order to put something in a character style:

  1. Take your hand off the keyboard
  2. Grab the mouse
  3. Insert
  4. Character Style
  5. Pick which character style
  6. Put your hands back at home position
  7. Type the content
  8. Press arrow or Esc

Or, you can apply it to an already written word:

  1. Take your hand off the keyboard
  2. Grab the mouse
  3. Highlight the word(s) to be applied
  4. Insert
  5. Character style
  6. Pick which character style

Doing it to already written content is obviously easier, but requires you to remember what needs characterstyling. Neither is optimal. So I combined the the info given me from Dominik Waßenhoven, Jürgen Spitzmüller, and Paul Rubin to create this new litt.bind, which implements my often used Charcode and Ex character styles, making it a simple keystroke to start them, and a simple Alt+M keystroke to "walk out of" the character style (like right arrow or Esc would do).

Here's my litt.bind:

\bind_file /usr/share/lyx/bind/cua.bind
\bind "M-9" "charstyle-insert Charcode"
\bind "M-y" "charstyle-insert Ex"
\bind "M-m" "char-forward"

I've tucked it off on a backed up corner of my directory structure, so that LyX replacemnts won't harm it, and because cua.bind is included by reference, it will take advantage of new cua.bind features, as opposed to the LyX help file's idea of making a copy of cua.bind.

This has made the use of character styles faster and easier for me -- I hope it does the same for some of you. Thanks Dominik, Jürgen and Paul!

SteveT

1.1  Much easier with Version 1.6

Beginning with version 1.6 binding keyboard shortcuts are easy:

  1. Open Preferences -> Editing -> Editing Shortcuts
  2. Type into the field "Show key-bindings containing" the word "layout"
  3. You can see in the field underneath a list of layout bindings
  4. Change or add you own bindings

Your shortcuts changes are stored in your local directory at ~/.lyx./bind/user.bind

Since LyX 1.6.0 renames charset-insert to much more flexible flex-insert, the previous example can be used as follows:

\bind_file /usr/share/lyx/bind/cua.bind
\bind "M-9" "flex-insert Charcode"

2.  How to define keyboard shortcuts for putting the selected text in color, while keeping all the properties of the text unchanged (boldness, size, etc.)

Put the following lines in ~/.lyx/bind/user.bind, or alternatively use the preference dialog to define these keyboard bindings. Resetting the color is achieved with color code 0 (M-s d shortcut below, d as "default"). The fact that the text properties are kept unchanged seems to be contradictory with e.g. "size 13" below. For me, and for the time being, it is a mystery.

Note: I have found the necessary information in the file src/LyXAction.cpp in LyX sources.

\bind "M-s c" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 6 language ignore toggleall false"
\bind "M-s m" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 7 language ignore toggleall false"
\bind "M-s y" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 8 language ignore toggleall false"
\bind "M-s r" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 3 language ignore toggleall false"
\bind "M-s w" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 2 language ignore toggleall false"
\bind "M-s g" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 9 language ignore toggleall false"
\bind "M-s d" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 0 language ignore toggleall false"
\bind "M-s b" "textstyle-update family 15 series 3 shape 5 size 13 emph 4 underbar 4 strikeout 4 uuline 4 uwave 4 noun 4 number 4 color 5 language ignore toggleall false"

To reset the properties of the selected text (color, font, boldness, etc.), use:

\bind "M-s n" "textstyle-update color 0 language ignore toggleall false"

UPDATE 2019-09-27 BY YUNLONG

LyX 2.3.3 on Ubuntu 19.04

FILE : ~/.lyx/bind/user.bind


## This file is automatically generated by lyx
## All modifications will be lost
Format 4
\bind "M-s m" "textstyle-update color 11"
\bind "M-s o" "textstyle-update color 13"
\bind "M-s p" "textstyle-update color 15"
\bind "M-s r" "textstyle-update color 16"
\bind "M-s t" "textstyle-update color 17"
\bind "M-s v" "textstyle-update color 18"
\bind "M-s g" "textstyle-update color 8"
\bind "M-s l" "textstyle-update color 10"
\bind "M-s b" "textstyle-update color 3"
\bind "M-s w" "textstyle-update color 19"
\bind "M-s y" "textstyle-update color 20"
\bind "M-s d" "textstyle-update color 0"
\bind "M-s c" "textstyle-update color 5"


Category: Character style, Keyboard shortcut Tips

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2019-09-27 20:35 UTC