[Tex/LaTex] LyX command(s) to insert WYSIWYG horizontal line, for keyboard shortcut

lyxmacrosrules

Using the menu entry Insert > Formatting > Horizontal Line I can insert a WYSIWYG horizontal line into a LyX document. I want to figure out the internal command(s) used to do this so I can set up a binding to do this via a keyboard shortcut. However, Tools > Preferences > Editing > Shortcuts doesn't show anything, and the functions listed under Help > LyX Functions doesn't show anything either.

I could make a binding to insert the \hrulefill LaTeX command, but that wouldn't be WYSIWYG.

Looking in the .lyx file, I can see that a WYSIWYG line is done by:

\begin_layout Standard
\begin_inset CommandInset line
LatexCommand rule
offset "0.5ex"
width "100col%"
height "1pt"

\end_inset


\end_layout

However, using a command-sequence of multiple self-insert to insert those lines one after the other doesn't work.

I'm using LyX version 2.1.2

Best Answer

Go to View > Messages Pane:

enter image description here

Then click on the "Settings" tab in the bottom right corner:

enter image description here

Then click on the "Selected" radio button:

enter image description here

Then double click on "User commands" so that "no" turns to "yes":

enter image description here

Then click on the "Output" tab:

enter image description here

Then do the action that you want to copy the shortcut of. In this case, insert your horizontal line. In the output tab at the bottom, you will see:

enter image description here

This tell us that the correct command is:

inset-insert line CommandInset line LatexCommand rule offset "0.5ex" width "100col%" height "1pt" \end_inset

Verify that the command is correct by inserting it directly into the mini buffer (Alt + X or View > Toolbars > Command Buffer) at the bottom of the screen:

enter image description here

Run the command by pressing return. If it has the desired effect, then you know you have the right command and can create the shortcut in the usual way.

Note that you can have one shortcut do multiple commands by using command-sequence.

Related Question