Remove/Add Line Breaks after Specific String using Sublime Text

Bernd picture Bernd · Oct 25, 2012 · Viewed 82.1k times · Source

Using Sublime Text 2 - Is it possible to insert a line break/text return after a specific String in a text file e.g. by using the FindReplace tool?

(Bonus question: Is it possible to remove all line breaks after a specific String)

Answer

Sara picture Sara · Oct 25, 2012

Here's how you'd do it on a Mac:

Command+F > type string > Control+Command+G > ESC > Right Arrow > line break


and Windows/Linux (untested):

Control+F > type string > Alt+F3 > ESC > Right Arrow > line break


The important part being Control+Command+G to select all matches.
Once you've selected the text you're looking for, you can use the provided multiple cursors to do whatever text manipulation you want.

Protip: you can manually instantiate multiple cursors by using Command+click (or Control+click) to achieve similar results.