Hello all,

I was trying to come up with a command-sequence that I could bind to a key to easily insert index references. The idea being that I could select the text that I wanted to have an index entry, press the command key, and LyX would insert something like this into the raw source of the document:

\begin_inset LatexCommand \index{this text will be an entry in the index}

\end_inset

The only way I could get the command-sequence to work was to do the following:


1. Place the inserted stuff in an ERT inset

2. Omit the LatexCommand keyword (otherwise it shows up on the printed page!)

So this is what the output looks like in the LyX source file:

\begin_inset ERT
status Collapsed

\layout Standard

\backslash
index{this text will be an entry in the index}
\end_inset

And this is the command-sequence used to produce it:


\bind "M-i" "command-sequence cut; paste; ert-insert; self-insert \index{; paste; self-insert }; inset-toggle;"

So this sequence works... ie. the selected text ends up being an index entry, but I just wanted to ask if there's a better way to do this. I am not sure that I feel so comfortable about the difference between the commands produced by my command-sequence and those produced by LyX when you do an index-insert.


Best wishes,
Greg



Reply via email to