MacOS – Text editor to search/replace newlines and tabs

macossoftware-recommendationtext-editor

A time-saving feature I often used while editing large text files (the kind used for batch processes of data exchanges, aka, "flat files" for feeds between multiple systems) was Notepad++'s extended Find/Change function where you can specify certain characters (such as tab, space, line feed, carriage return) in both the Find function and the Change function.

This is the detail on how it works:

Open the find/replace dialog. At the bottom will be some Search mode
options. Select "Extended (\n \r \t \0 \x…)" In either the Find
what or the Replace with field entries, you can use the following
escapes:

  • \n new line (LF)
  • \r carriage return (CR)
  • \s space character
  • \t tab character

This would make it very easy to edit lists of information, changing files from comma to tab delimited, or files with spaces between into comma delimited, as well being easy to go from spaces to tabs (or visa versa).

Anyone happen to know which text editors running on Mac OS have this feature (or have plugins to add this functionality)?

Best Answer

Text Edit which is available out of the box supports searching for special characters:

  • Access "find" functionality with Cmd-F
  • Click the small magnifying glass at the beginning of the entry field and select "Insert Pattern" (last entry)
  • Pick your pattern (and repeat if necessary)

enter image description here

  • Move the cursor to the replacement field to select a pattern there (or just copy/paste from the search field)

If you do a lot of text-based file processing it might help to spend some time to learn about basic Unix tools like awk, sed and friends. This would make thinks a lot easier on the long run.