如何在Sublime Text 4中将每3行UUID文本合并为单行?
Solution for Merging Every 3 Lines in Sublime Text 4
To merge each set of 3 UUID lines into a single line in Sublime Text 4, use this regex-based find-and-replace workflow:
Step-by-Step Instructions
- Open your UUID file in Sublime Text.
- Press
Ctrl+H(Windows/Linux) orCmd+H(Mac) to open the Find/Replace panel. - Enable Regular Expression mode by clicking the
.*button in the panel. - Enter these patterns:
- Find What:
('.*',)(?:\R|$)('.*',)(?:\R|$)('.*',)(?:\R|$) - Replace With:
$1 $2 $3\n
- Find What:
- Click Replace All to apply changes to the entire file.
Explanation
- The
Find Whatpattern captures three complete UUID lines (each ending with a comma and either a line break or end of file) into separate groups ($1,$2,$3). This fixes your original regex issue, which captured all three lines as a single group instead of individual entries. - The
Replace Withstring combines the three groups into one line, separated by spaces, and adds a trailing newline to match your desired output structure. \Rmatches any line ending (LF, CRLF, CR), ensuring compatibility across different operating systems.
Handling Non-Multiples of 3
If your file has leftover lines (1 or 2 lines not part of a triplet), they’ll remain unchanged. To merge these too:
- For pairs: Use
('.*',)(?:\R|$)('.*',)(?:\R|$)and replace with$1 $2\n - Single lines: No action needed—they’re already in the correct format.
Content of the question originates from Stack Exchange, asked by Bitswazsky
相关产品推荐
相关产品推荐

