Replacing all special/accented characters with equivalent regular characters in Notepad++

find and replacenotepad

I'm trying to figure out a way to automatically search and replace all special/accented letters/characters (such as Â/Ô) with the equivalent regular letters/characters (A/O) in Notepad++.

Tried using ToolFx but it didn't work.

Best Answer

The suggestion above is excellent, but in this very moment it would not work because of an issue between Notepad++ and "Notepad++ Python Script". Since some months Notepad++ plug in manager downloads an old Python Script version that won't work with the editor. To fix that:

  1. Exit Notepad++
  2. Download the compatible version from SourceForge.
  3. Run the downloaded installer by double clicking it. On newer Windows it'll ask to switch to Administrator privileges.
  4. Make sure to pick the correct install drive at the beginning of the install process. It won't detect the Notepad++ installation disk correctly. I had to reinstall it again because by default it installs on C:\ even if Notepad++ is on another disk.
  5. Follow the wizard instructions.
  6. Once finished with the install process, (re)start Notepad++. Now go and open the Plugin menu. You should see a new "Python Script" item inside it. If it appears then you have force-installed the correct version well. You may also double check by opening the Plug in manager, going to the "Installed" tab and looking for an entry showing version 1.0.8 (at this time) of the Python plug in being present.
  7. You are almost done. Go to the Plugins => Python Script => Show console menu. A pane shall appear at the bottom of Notepad++. It MUST show a prompt like the following:

    Python 2.7.6-notepad++ r2 (default, Apr 21 2014, 19:26:54) [MSC v.1600 32 bit (Intel)]
    Initialisation took 156ms
    Ready.
    

The various version numbers are current as of today, of course they shall change as time goes on. If the bottom pane shows an exception stating an exception occurred or (and) it stays blank, then you have installed a wrong Python plug in version.

Now, let's apply the script in the correct way:

  1. Open two new, blank tabs/files.
  2. Paste your accented text in the first.
  3. Right click the tab of the second and select the 'Move to Other View' menu. The Notepad++ windows will split.
  4. Open the Python Script console as explained above (Plugins => Python Script => Show console menu).
  5. Go to the console line at the bottom of the Python pane, it has a ">>>" marking at its beginning.
  6. Type: from Npp import * and then press Enter (from now assume you'll always press Enter at the end of the commands).
  7. Enter: import unicodedata in the same input text.
  8. Click (select) the tab containing the accented text (this is important!).
  9. Enter the following commands, one line at a time, in the Python prompt and then press Enter after each line:

    eText = editor.getText()
    uText = unicode(eText, "UTF-8")
    nText = unicodedata.normalize( "NFKD", uText )
    

If you want to be sure Python "really got the text in": after you typed eText = editor.getText() (+ Enter key), enter: print eText + Enter. You should see your accented text dumped in the Python console output pane.

  1. Click (select) the empty tab (this is important!).
  2. Enter: editor.addText( nText.encode('ASCII', 'ignore') ) in the usual Python console command input text box.
  3. The empty tab shall fill in with the converted, accent-less text. Make sure to follow this to-do list carefully because it's easy to miss a step (expecially clicking the tabs) and then you'll have to restart from scratch.
Related Question