1

I tried extended search --> replace with \0, but it does not seem to work. Instead it deletes all occurrences of the character. Could it be a bug?

NB: replacing with \n, \r\n and the like works in extended search.

I am using Notepad++ 6.4.1 Unicode.

5 Answers5

2

Searches on the internet showed that inserting NUL in Notepad++ is non-trivial, for example see How to Insert a Null Character (ASCII 00) in Notepad?

A hackish way to replace given character/characters with NUL is via the Hex Editor Plugin.

  1. Go to hex mode (via Plugins → HEX-Editor → View in HEX, or Ctrl+Alt+Shift+H)
  2. Highlight the character(s) you want to replace.
    • You can either highlight it in the "Dump" column or in the "0 | 1 | ... | f" column.
  3. Ctrl+H to bring up the Replace menu.
    • Change "Data type" to "Hexadecimal".
    • The character(s) you highlighted will show up under "Find what" (as a hex string)
    • Enter "00" in the "Replace with" field (that is a null byte)
  4. Press "Replace" or "Replace all".

Disclaimer: I've heard from somewhere that the Hex Editor plugin is buggy but I've only used it occasionally in the past (it worked alright but your mileage may vary) so I don't really know the extent of its bugginess.

You can install it via Notepad++'s Plugin Manager (Plugins → Plugin Manager → Show Plugin Manager) but you might need to check "Show unstable plugins" under Plugin Manager's "Settings" for the plugin to show up

doubleDown
  • 1,082
  • 8
  • 10
1

Try \d### (where # is a single digit in the 0-9 range).

See Escape sequences supported in extended mode for more.

Edit: Looks like \d, \u, \x etc. don't work properly when it comes to replacing with the NUL character. Search works fine (I inserted a few NULs using a hex editor), but replace doesn't and simply deletes the characters.

Karan
  • 57,289
1

As far as I know Notepad++ has always had issues with inserting 0-characters.
Notepad++ is no exception: Most editors can't deal properly with it.
It is not really surprising. Dealing with 0-characters is quite a niche application.

The only Windows editor that I am aware of that can handle 0's as any other character is UltraEdit.
(And it has an hex-edit mode as well, so one way or another you can get the job done with it.)

Tonny
  • 33,276
1

Reported it as a bug here - please comment there in hope it's fixed - looks like a possible can of worms to me.

References :

0

How to insert any byte value into a text:

  1. Npp -> Plugins -> Python Script -> New Script
  2. Select where to save ... and give the name insert a byte (say)
  3. in opened Npp doc insert this code:

        s= notepad.prompt('Enter value, or series, in a box, e.g.: \x5Cx00 ','Insert a byte ')
        exec("a=b'{}'".format(s))
        editor.addText(a)
    
  4. Save.

  5. Restart Npp

  6. Then you must see own script under menu:
    Npp -> Plugins -> Python Script -> Script -> insert a byte
  7. If you want shortcut for this, please see how to: Wrap Text with Quotation Marks in Notepad++
Avtokod
  • 101
  • 3