Community
    • Login

    Display control characters as empty character or as spacing

    Scheduled Pinned Locked Moved General Discussion
    10 Posts 5 Posters 11.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • NN---N
      NN---
      last edited by

      Notepad++ uses Scintilla which displays control characters as rectangle with text.
      I want an option to not show these characters and to have option to replace it with space.
      I tried View->Show Symbol->Show whitespace and tabs
      But it didn’t help.
      Notepad++ still displays nul character as ‘NUL’.

      Is there option to do this ?

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        If you have PythonScript plugin installed, go to the Plugins > PythonScript > Show Console and type:

        editor.clearRepresentation("\x00")
        

        in the >>> line, and hit RUN. This should make the NUL display as a blank character. To display NULs per NPP’s normal,

        editor.setRepresentation("\x00", "NUL")
        

        If that works for you, use the Plugins > PythonScript > New Script, create a script “Display NULs as SPACEs”, which contains just that first line. (I’d also make a second script “Display NULs as NUL” to be able to revert to normal display)

        If you use Plugins > Python Script > Configuration, you can then put those scripts into the main Macro menu, and using Settings > Shortcut Mapper > Plugin Commands, you can assign a keyboard shortcut to those scripts.

        1 Reply Last reply Reply Quote 0
        • NN---N
          NN---
          last edited by

          Thanks. I will check what the script does and just write a plugin or PR for N++.

          PythonScript doesn’t have 64-bit version.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @NN---
            last edited by

            @NN—

            Why would you want to do this? Seems like you would just be hiding content, which sounds like a bad thing (without knowing more)

            1 Reply Last reply Reply Quote 0
            • NN---N
              NN---
              last edited by

              Notepad++ has huge performance issues when there are many control characters displayed.

              1 Reply Last reply Reply Quote 0
              • V S RawatV
                V S Rawat
                last edited by

                I also face problem about this.
                each character should have single char width.

                NUL, CR, LF become too long. And are actually ugly and horrifying looking.

                I wanted some invisible chars to be displayed but I got scared seeing them displayed in their current dress-up, so I had to stop displaying them.

                for every invisible character, please use a single char display method.

                like MS Word uses single chars for for paragraph mark and soft hyphen mark.

                –
                Rawat

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038

                  Hello, @nn and @v-s-rawat,

                  To replace all CO controls and C1 Controls by a specific character, you could also use a simple regex S/R

                  Refer to these special code-points, clicking on the links below :

                  http://www.unicode.org/charts/PDF/U0000.pdf

                  http://www.unicode.org/charts/PDF/U0080.pdf

                  So :

                  • For files with an ANSI encoding or a specific encoding ( Encoding > Character Sets > … ), use the following regex S/R :

                  SEARCH (?!\t|\r|\n)[\x00-\x1f]

                  REPLACE a SPACE ( or any other single character ! )

                  • For files with an Unicode encoding ( UTF-8, UTF-8 BOM, UCS-2 LE BOM and UCS-2 BE BOM, use, instead the S/R, below :

                  SEARCH (?!\t|\r|\n)[\x00-\x1f\x80-\x9f]

                  REPLACE a SPACE ( or any other single character ! )

                  Best Regards,

                  guy038

                  P.S. :

                  Of, course, due to the negative look-ahead (?!\t|\r|\n), any character replaced, at current position, must be :

                  • Different from the tabulation character ( \t )

                  • Different from the two End of Line characters ( \r and \n )

                  1 Reply Last reply Reply Quote 0
                  • NN---N
                    NN---
                    last edited by

                    Replacing is not a suitable solution since I have a log file which is changing each second.
                    I just want to see space instead of control character.
                    Seems like it is possible by calling API SCI_SETREPRESENTATION .

                    1 Reply Last reply Reply Quote 0
                    • guy038G
                      guy038
                      last edited by guy038

                      Hi, @nn,

                      Oh, I see ! Of course, my proposed static replacement is quite useless, in your case :-(( Sorry and… good luck for implementing the Scintilla API SCI_SETREPRESENTATION !

                      Cheers,

                      guy038

                      1 Reply Last reply Reply Quote 0
                      • V S RawatV
                        V S Rawat
                        last edited by

                        I mean, if Replacing is the only solution,
                        hope someone develops a replacement table/ code that would change all control characters display to as used in MS Word/Excel.

                        Then it would be easy for us NON-programmer to use such a table.
                        Thanks.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors