Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24102
    LTT
    Participant

    Text:
    11111
    222
    (Empty line)
    4444444(EOF)

    Goal:
    11111
    11111
    222
    222
    (Empty line)
    4444444
    4444444(EOF)

    So I made a snippet “Duplicate Lines Interlaced” (1):
    ${0:${SelText/.+(\r?\n|\r)/\0\0/g}}
    ▲?1: Have to use \r and/or \n exactly. Can this be simplified in Snippets?
    ▲?2: Newlines are consistent in the result. Is it possible to keep the original?
    ▲?2+: Note that the length of the selection in the result could be shorter or longer than expected, if the original newlines are inconsistent.
    ▲?3: This snippet can not handle the EOF line. How to handle EOF in Snippets?

    Snippet “Duplicate Lines Interlaced” (2):
    ${0:${SelText/.+/\0\n\0/g}}
    ▲ This one can handle the EOF line. But apparently the newline issues still exist.

    #24186
    LTT
    Participant

    Can this be optimized?
    Or are there any tricks for such cases?

    #24200
    Yutaka Emura
    Keymaster

    The issue is not easy to fix. How about writing a macro to work around the issue?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.