Replace special characters in rich text fields

Can I batch search & replace return characters in OmniOutliner rich text fields, if not in the interface, then via a script?

The import function of Airtable glitches over the returns in rich text fields, splitting the contents over multiple rows.

Yes, both in the standard Find dialogue and also with a script.

The easiest approach is to simply select an example return in one of your documents and type ⌘-e, which will make the selection the ‘find string’ in the find dialogue, which you can then open. In the ‘replace’ field, type a space (or whatever replacement characters) and click ‘replace all’. Of course, you could also copy the selected return to the clipboard and then paste it into the ‘find string’ field.

Alternatively, as there are some text areas, typically in dialogues, which treat the ‘return’ key as an accept key and sometimes you don’t have anything to select/copy, you can also type a return with control-option-m (or the linefeed with control-option-j). As far as I can recall, this keyboard shortcut should work as is with a US keyboard selected.

1 Like

And, to do this via applescript, try this:

tell application "OmniOutliner"
	tell document 1
		repeat with x in rows
			replace (topic of contents of x) replacement space string return -- linefeed
		end repeat
	end tell
end tell
1 Like

It’s so simple I’m a bit embarrassed I didn’t think of that myself. Thanks!