|
Edit Links |
Tips /
CommandSequencesCategories: Uncategorized << FrequentlyUsedShortcuts | Page list | CommandSequencesTips >>Creating keyboard macrosYou 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
ExamplesBelow is a list of miscellanous command sequences that can be used for defining your own keyboard macros. Convert to latex commandThis 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 commandEx: "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 ERTThis 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 classThis 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" paragraphsThese 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 bufferThis 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 figureInsert 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" |