- AuthorPosts
- January 2, 2019 at 2:26 am #24102LTTParticipant
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.January 15, 2019 at 4:06 am #24186LTTParticipantCan this be optimized?
Or are there any tricks for such cases?January 18, 2019 at 1:19 pm #24200Yutaka EmuraKeymasterThe issue is not easy to fix. How about writing a macro to work around the issue?
- AuthorPosts
- You must be logged in to reply to this topic.