Go to page:

Search help:

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

CommandSequences

Categories: Uncategorized
<< FrequentlyUsedShortcuts | Page list | CommandSequencesTips >>

Creating keyboard macros

You can make your own keyboard macros by by adding a line like this to your .bind-file, (create your own bind-files in the LyX/UserDir)

  \bind "C-a"  "command-sequence math-mode; math-insert \myPI;"   

\myPI is just some made up latex-command in this example. Also see Tips.KeyboardShortcuts.

Tips for creating command sequences

  • See CommandSequencesTips for tips on how to create and test your command sequences using the mini-buffer in LyX.
  • See LyxFunctions for a list of LFUNs (i.e. commands) that can be used in command sequences.
  • The LFUN self-insert is very useful. Note that it can insert several characters at once: "command-sequence self-insert All of this is inserted;"

Examples

Below is a list of miscellanous command sequences that can be used for defining your own keyboard macros.

Convert to latex command

This sequence converts the marked region into a latex command (i.e. '\' is added in front and {} is appended):

  "command-sequence cut; ert-insert; self-insert \; paste; self-insert {}; inset-toggle;"  

This sequence selects the current word, cuts and pastes it inside an ERT as a latex command:

  "command-sequence word-select; cut; ert-insert; self-insert \; paste; self-insert {}; inset-toggle;"  

Convert selection to argument of a latex command

Ex: "Using EFDO gives bla bla" -> "Using \lsc{EFDO} gives bla bla"

  "command-sequence cut; ert-insert; self-insert \lsc{; paste; self-insert }; inset-toggle;"  

Indent marked text using ERT

This command sequence cuts the marked text, inserts an ERT, the marked text and then a second ERT. The ERT's adjusts the left margin, making the text become indented."

  "command-sequence cut; ert-insert; self-insert {\addtolength{\leftskip}{1cm}; inset-toggle; paste; break-paragraph; ert-insert; self-insert }; inset-toggle;"  

Note that the entire first paragraph that is marked will be indented. Also note that a break-paragraph will be inserted just before the last ERT, which means that if the selected text ends in the middle of a paragraph, the paragraph will be broken there.

Songbook class

This sequence is used to cut marked characters and paste them into a math-macro called \Ch (short for Choord).

   \bind "M-S-C"   "command-sequence math-mode; line-end; math-insert \Ch; char-backward; line-begin-select; cut; char-forward; paste; down;"  

Cursor movement up/down "between" paragraphs

These bindings requires a patch by Alfredo, that makes the cursor become horizontal when a new paragraph is inserted. This is a patch under development, and not part of the standard lyx versions.

  \bind "C-Up" "command-sequence paragraph-up; break-paragraph;"
\bind "C-Down" "command-sequence char-forward; paragraph-down; break-paragraph;"  

Adding a comment with the text: "Add stuff"

This sequence adds a new paragraph in the Comment layout, with the text "Add stuff". It's supposed to be a reminder for you to add stuff later on"

  "command-sequence paragraph-down; char-backward; line-end; break-paragraph; depth-increment; layout Comment; self-insert Add stuff\?;"   

Starting the spellchecker from the beginning of the buffer

This command sequence places a bookmark (called before-spellcheck) at the current position, then goes to the beginning of the buffer, and finally starts the spellchecking.

  "command-sequence bookmark-save before-spellcheck; buffer-begin; spellchecker;"  

You can use this command sequence to go to the bookmark.

  "command-sequence bookmark-goto before-spellcheck;"  

These two command sequences could then be bound as follows: \bind "S-F7" "command-sequence bookmark-save before-spellcheck; buffer-begin; spellchecker;" \bind "C-F7" "command-sequence bookmark-goto before-spellcheck;"

It doesn't work to put "bookmark-goto before-spellcheck" at the end of the first command sequence, since you get some kind of interference between the spellchecker and going to the bookmark.

Inserting a figure float with centered figure

Insert a figure float, open a paragraph for the actual figure, insert \centering as ERT, open the figure-file dialog

 \bind "C-S-B"     "command-sequence float-insert figure; break-paragraph; ert-insert; self-insert \centering ;inset-toggle;graphics-insert"

Uncategorized

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2006-09-16 14:07 CEST