87

If the free source code editor Notepad++ has the feature "Find in files...", that is without the files being opened in the editor, does it also have the feature "Replace in files..."?

Notepad++ is based on the editing component Scintilla - for which at SourceForge there is a response to a request for this feature: "No need for this to be included in SciTE as you can add this command to the Tools menu using the Parameters dialog." So is it possible to do multi-line replace in files in Notepad++?

3
  • The question was "Missing/desired features in Notepad++", but that would have distracted too much from what I'm particularly trying to find out, and it might have got the question closed.
    – Rob Kam
    Commented Jan 1, 2009 at 12:41
  • Pray tell how the question isn't constructive..
    – Drew Alden
    Commented Sep 3, 2014 at 18:14
  • Here is a utilitarian solution. stackoverflow.com/a/13892643/5017758 Commented Jul 28, 2020 at 2:38

4 Answers 4

90

It's easy to do multiline replace in Notepad++. You have to use \n to represent the newline in your string, and it works for both search and replace strings. You have to make sure to select "Extended" search mode in the bottom left corner of the search window.

I found a good article describing the features here: http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html

6
  • This is in a file already open. The question is how to do it in files without opening them in the editor. e.g. Replace all occurrences of foo with bar in files *.c in folder bas.
    – Rob Kam
    Commented Nov 2, 2010 at 7:46
  • 6
    You can do it for unopened files as well. It's the "Search->Find in Files" options in the menu or use the keyboard shortcut Ctrl-Shift-F
    – Alex
    Commented Nov 5, 2010 at 14:49
  • This is the answer, this should have been marked as the answer +1 Commented Jul 27, 2011 at 20:43
  • 3
    It's way easier using ToolBucket plugin for Notepad++ to multiline edit. Check my answer to more info. Commented Aug 31, 2015 at 16:16
  • 1
    It does require you though to make sure that the text contains none of those extended symbols or escape them beforehand.
    – makrom
    Commented Jun 30, 2020 at 16:44
88

Actually it's way easier to use ToolBucket plugin for Notepad++ to multiline replace.

To activate it just go to N++ menu:

Plugins > Plugin Manager > Show Plugin Manager > Check ToolBucket > Install.

Restart N++ and press ALT + SHIFT + F to multiline edit.

6
  • 1
    Worked perfectly, and I didnt need to install another editor! I was surprised that neither VS or emacs does this in an easy way.
    – sandos
    Commented Jan 29, 2016 at 9:11
  • 5
    The question is about replacing in [multiple] files. Commented Aug 11, 2016 at 13:58
  • 2
    @MarkusvonBroady you can find and replace in multiple files with this method Commented Oct 3, 2016 at 1:10
  • 2
    @ArturHaddad Yes, if you first open all of them, which can be problematic for a lot of files, but technically you're right. Aside from the need to open possibly a lot of files, you also may need a tool to automatically discover and open files in subfolders. Commented Oct 3, 2016 at 10:04
  • 3
    Note that as of 2018, the plugin manager is no longer included in notepad++, you'll have to manually install plugins or re-install the plugin manager yourself.
    – James Wong
    Commented Aug 23, 2018 at 10:00
14

The workaround is

  1. search and replace \r\n to thisismynewlineword

(this will remove all the new lines and there should be whole one line)

  1. now perform your replacements

  2. search and replace thisismynewlineword to \r\n

(to undo the step 1)

2
  • While not an elegant solution, I had to use exactly this approach when doing a large, multiline search and replace within a Windows text editor.
    – siliconpi
    Commented May 16, 2012 at 16:08
  • If your replacement text doesn't contain escaped characters which are parsed by extended method (\n, \r, \t etc.) then you can make it easier by simply replacing \r\n with \\r\\n with no need to change anything back. Commented Aug 11, 2016 at 14:32
3

Notepad++ is still up and going so also you can install plugin ToolBucket from menu Plugins -> Plugin Manager. It doesn't improve native Notepad++'s Search and Replace dialog but uses its own with shortcut keys Alt+Shift+F

enter image description here

1
  • And this will not work with find/replace in files...
    – kipusoep
    Commented Jun 19 at 12:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.