Line Actions
The actions of the Text ⟩ Lines menu work on whole lines: the lines that are selected, or with no selection, every line of the document.
Text ⟩ Lines ⟩ Sort Ascending and Sort Descending
Put the lines in order. Lines are sorted as the Finder sorts names: capitals and small letters are sorted together, and numbers by their value, so that item 9 comes before item 10.
Text ⟩ Lines ⟩ Reverse
Puts the lines in the opposite order, the last line first.
Text ⟩ Lines ⟩ Remove Duplicates
Where a line occurs more than once, keeps the first and removes the others. Lines must be exactly the same to count as duplicates.
Text ⟩ Lines ⟩ Remove Blank Lines
Removes the lines that have nothing on them.
Text ⟩ Lines ⟩ Lines Containing…
Finds the lines that contain some text, and then does one of three things with them:
- Delete them
- Delete the others, keeping only the lines that contain the text
- Copy them to the clipboard
Check Regular expression to look for a pattern rather than literal text, and Match case to tell capitals from small letters.
For example, to see only the errors in a log, look for lines containing error and delete the others.
Text ⟩ Lines ⟩ Join (control J)
Makes one line of the selected lines, with a single space between what was on each. Blank lines are dropped. With nothing selected, Join joins the line the cursor is on with the line below.
Text ⟩ Lines ⟩ Prefix and Suffix…
Adds text to the start of each line, the end of each line, or both. What goes before a line goes after its indentation, and blank lines are left alone.
For example, to make a list of a run of lines, add <li> before and </li> after.