[Tex/LaTex] Lyx Current Date Keyboard Shortcut

keyboardlyx

I'm trying to create a keyboard shortcut to add date to my class notes in Lyx so that they are organized better. I want the shortcut to add the notes on the left.

That is, I just want to add the following, with the current date each time.

enter image description here

The following keyboard shortcut does half the job:

command-sequence ert-insert; self-insert \reversemarginpar; char-forward; marginalnote-insert; self-insert 2017-05-07; char-forward

However, the date is not assigned dynamically. Is it possible to make the date be filled automatically based on current writing (not compiling) date?

Best Answer

The solution is to use the LyX command date-insert instead of self-insert. It receives a parameter for the date format, in strftime format (e.g. %Y-%m-%d).

I.e., the full keyboard binding is:

command-sequence ert-insert; self-insert \reversemarginpar; char-forward; marginalnote-insert; date-insert; char-forward

All the commands appear in LyX Wiki, but without much documentation. The source code contains complete and thorough documentation, so it is easier to find the needed commands there.

As for possibility to use self-insert for dynamic input, by looking at the source, it seems that it only copies the text as is, as if it was inserted using keyboard.

Related Question