7

In the code editor of IntelliJ 2018, using either menu item:

  • Edit > Find > Find…
  • Edit > Find > Replace…

enter image description here

…how can I find invisible (non-printing) characters?

I am referring to characters such as:

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154

1 Answers1

10

Enabling "Regex" checkbox, you can use the full regex syntax. I was able to search for spaces with \u0020 and for LF with \x0a.

  • Carriage return and line feed match \r and \n respectively.
  • Arbitrary Unicode character syntax: \uFFFF, where FFFF is a hex Unicode character code.
  • Arbitrary ASCII character syntax: \xFF, where FF is an ASCII hex code.
Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
  • For completeness, after enabling Regex checkbox, what *exactly* would you type to search for a single specific Unicode code point? I am not Regex-savvy, and your linked page confused me further. – Basil Bourque Jul 12 '18 at 19:34
  • Updated, this should be it. – Victor Sergienko Jul 12 '18 at 19:40
  • This works. For example, I was able to use the "Replace all" button after enabling "Regex" checkbox to replace every occurrence of `\n>` in quoted-block-text with `\n\n>` to accomplish double-spacing-between-lines. Thanks. – Basil Bourque Jul 12 '18 at 21:21
  • 1
    Victor (or Basil's edit?) is wrong: `CR = carriage return = decimal 13 = hex 0d`, while `LF = line feed = decimal 10 = hex 0a`. See [this code chart](https://theasciicode.com.ar/). I am currently using the latest version of IntelliJ, 2018.3.2. Using that version, `\n` or `\x0a` finds line feeds. However, neither `\r` nor `\x0d` finds carriage returns. Yet I know that my file has both! TextPad finds both, and IntelliJ itself displays that my file's line endings are CRLF. Is this an IntelliJ bug? – HaroldFinch Jan 03 '19 at 14:16
  • 1
    Updated the answer. Indeed it doesn't work in the current version. I filed a bug: https://youtrack.jetbrains.com/issue/IDEA-204958 – Victor Sergienko Jan 03 '19 at 19:07
  • Victor: many thanks for filing the bug report! I think that you still need to edit your answer, however. I suggest: Line feed should match `\n` or `\x0a` while carriage return should match `\r` or `\x0d`. – HaroldFinch Jan 04 '19 at 14:55
  • You could also note that other regular expression engines have slight variations here. For example, the text editor TextPad treats `\n` and `\r` identically: both match either a line feed, a carriage return, or a combined (DOS style) carriage return followed by a line feed. – HaroldFinch Jan 04 '19 at 15:02
  • \t for tab char – Javier Torón Apr 03 '19 at 13:54
  • You're a Lifesaver ! Thanks a lot. But only `\u200` worked and not \u200\ – Selast Lambou Aug 06 '20 at 13:08