On 02/22/2018 03:37 PM, Richard Heck wrote:
On 02/22/2018 03:05 PM, Joel Kulesza wrote:
On Thu, Feb 22, 2018 at 12:52 PM, Daniel Gómez Martínez <dangome...@gmail.com <mailto:dangome...@gmail.com>> wrote:

    Hello everyone,

    I have large sections of customized TeX code in the LaTeX
    preamble of some LyX templates I've created over time. I would
    like to know if there's a way to quickly toggle between commented
    and uncommented line for a given selection of lines (say, with a
    keyboard shortcut)


I don't know of a way to do this.

    , and in case there's not a quick way to do this, I would like to
    ask the developers if they can include this feature in
    Settings->Document->LaTeX Preamble and in the TeX code environment


I would be happy to see this also.

    (the one you have with Ctrl+L), it would also be great if a
    message of how to do so (toggle comment lines keyboard shortcut)
    could be included in the Settings->Document->LaTeX Preamble
    sub-window.

    I'm sure I've read somewhere that LyX tries to the highest extent
    to be so complete that users don't usually have to put TeX or
    Preamble code lines, but as we users have some really customized
    and variable needs


The approach I use is to write a separate, external, preamble.tex file that I then put alongside the .lyx file and in LyX's premable I issue "\input{preamble.tex}".  Then, I can (un)comment the contained behavior in one line.  Naturally, one can use multiple preamble files to segregate behaviors.  Using this approach also allows multiple documents to share a common preamble.  Further, by symbolically linking the .tex file, an update in one instance updates behaviors globally.

If one's preamble-related needs have become this sophisticated, then I'd recommend this approach. I don't think we really want to implement a full-fledged LaTeX editor inside LyX. What might be more plausible, and something I think we have considered, is to have some way to launch an external text editor and then read back whatever's provided, kind of like we do with graphics (say).
We already have line-begin, self-insert and char-delete-forward LFUNs. If someone were to add a "for-each-selected-line" LFUN (with a shorter name) that would take a command or command-sequence as its argument, block comment/uncomment could be done as a macro.

Paul

Reply via email to