32

Is there a way to find a paragraph?

For instance I want to search for this code:

<?php
    $radio_buttons++;
  }
?>

But when I try to copy that into the search box it only copies the first line, <?php.

It seems like there is definitely a way to do this, but I just can't find it. Maybe it is an addon?

3
  • I'm on a Mac right now so can't check, but I seem to recall that Notepad++ allows you to specify regular expression in the search field?
    – Matti Lyra
    Commented Mar 30, 2011 at 16:26
  • Yes it does but I still can't paste in more then a single line
    – Sackling
    Commented Mar 30, 2011 at 16:27
  • 1
    Refer to this stackoverflow.com/questions/405002/…. Looks like Notepad++ doesn't support multi-line search yet. There might a plugin for it but none that I've heard of. Commented Mar 30, 2011 at 16:28

11 Answers 11

60

I wrote a multiline search and replace add on for Notepad++, check it out here: http://www.phdesign.com.au/programming/toolbucket-multi-line-search-plugin-for-notepad/

ToolBucket Screenshot
(source: phdesign.com.au)

11
  • 1
    This is great stuff. Thank you.. It was still a problem many months later and this works perfectly. If I did have just oneee tiny nitpick it is that using ctral + A to select all, which I do to erase a previous search does not seem to work.
    – Sackling
    Commented Mar 7, 2012 at 14:58
  • 1
    Thank you for developing that very useful tools. I've installed them to my desktop and portable versions of Notepad++. I'll recommend them to my colleagues. Commented Mar 27, 2012 at 21:45
  • +1 and thank you! I like that you made the find and replace similar to dreamweaver's GUI. The only thing missing is the option to save regexes.
    – t.mikael.d
    Commented May 6, 2012 at 10:03
  • 2
    The plugin does not work with me with Notepad++ 5.x.x. But it works like charm with 6.x.x
    – MohamedEzz
    Commented Oct 18, 2012 at 7:13
  • 3
    Thank you for this wonderful plug-in, I work with lots of documents that require a multi-line search and replace feature. It's so nice that you have provided this great tool for the community. Thank you!!
    – klewis
    Commented Feb 5, 2013 at 22:30
23

As Xenovoyance suggests, it is possible with CTRL+R (also found in menu option TextFX > TextFX Quick > Find/Replace):

Just select your text to find, then invoke that option... Multi line find/replace

UPDATE: User Żabojad made me realise that in the latest releases of Notepad++, the "TextFX" plugin is not installed by default, so first you'll have to do one of two things:

  1. The easiest one: Go to menu option Plugins > Plugin Manager > Show Plugin Manager, scroll the available plugin list to "TextFX Characters" and install it. Install from Plugin Manager

  2. The above way should work, but otherwise you'll have go to this page : http://sourceforge.net/projects/npp-plugins/files/TextFX/TextFX%20v0.26/ and download file TextFX.v0.26.unicode.bin.zip Download TextFX Characters then extract its contents (don't just copy zip file) to the \plugins subfolder of the Notepad++ Install Folder Copy dll to Notepad++ plugins folder

After restarting Notepad++ you'll see the menu entry TextFX.

2
  • 3
    Unfortunately this plugin doesn't seem to support editing multiple open documents either. Commented Mar 24, 2013 at 14:12
  • Ctrl+R didn't work for me until I went into Settings > Shortcut Mapper, and clicked on the "Reload from disk" line and clicked Clear to remove the conflicting Ctrl+R shortcut. Commented Jul 11, 2019 at 17:43
9

Since Notepad++ 6.0 the regular expression search for multiple lines works.

The search for your code would be something like

<?php.*\r\n.*$radio_buttons++;.*\r\n.*}.*\r\n.*?>

.* is just wildcard for any number of characters (except line breaks). You can also toggle a checkbox in the Notepad++ dialog (called . matches newline) to include line breaks.

For a detailed description see the top answer of this question:

Find CRLF in Notepad++

0
8

Cntrl+C the above text you want to find and Cntrl+V it into a new blank document in Notepad++, then Select it again and hit Cntrl+F . You will see your text into the "find" field with tabbed spaces as the line breaks. No need for plugins.

1
  • Confirmed in Notepad++ 6.6.9. You can check the actual search string in the <Find ...> sections within <FindHistory...> in Notepad++'s "config.xml" file.
    – AdrianHHH
    Commented Dec 23, 2014 at 8:39
4

To my knowledge Notepad++ doesn't support multi-line regular expressions, so you'll have to do this by replacing every line break with the representative line break characters for your operating system (most likely \r\n). See Find CRLF in Notepad++ for details.

2
  • The problem is if you paste the paragraph into Search box, all you get is '<?php'. That is an awful lot of work just to type one paragraph into a search box. Commented Mar 30, 2011 at 16:30
  • Not really - you can use the extended search to replace all \r\ns with some unused character (tilde, pipe, etc.), then use the non-extended search to replace that character with \r\n again (with non-extended \r\n will not create new lines). Voila - the search string. Also, you can make a macro out of this fairly easily. Commented Mar 30, 2011 at 17:13
3

I found the following thread on a related subject: Multiline Regular Expression search and replace!

Recommend that you try out CTRL + R!

5
  • trying CTRL + R it does not seem to be working. Not sure which options to have selected yet.
    – Sackling
    Commented Mar 30, 2011 at 16:36
  • I just tried it on my machine here (notepad++ 5.8.6) and I could search for a multi-line blog of text. Perhaps running an older version? Commented Mar 30, 2011 at 16:39
  • yep I was on 5.8.6 and actually just updated to .7 it seems to work sometimes** like in a paragraph on a txt file but doesnt seem to like when searching for a block of code with white space between it. Maybe it is an option I am missing.
    – Sackling
    Commented Mar 30, 2011 at 17:27
  • Just realized "selection" was ticked off it seems to work now! Thanks!
    – Sackling
    Commented Mar 30, 2011 at 17:30
  • It's really through the plugins Notepad++ really start to shine. Glad to help! Commented Mar 30, 2011 at 19:38
3

Multiple lines can be passed to search and replace fields only when lines endings are set to Unix form. This can be done via Edit>EOL Conversion>Unix

Then you can manually copy multiple line paragraph to search field.

After that, just convert line endings back to Windows via Edit>EOL Conversion>Windows

1
  • 1
    Nice, no need any extra plugin Commented Jan 2, 2019 at 3:40
2

For a Notepad++ v5.8.7+ there is no TextFX plugin for Unicode installed by default, so in order to use CTRL+R you need to install TextFX Characters plugin with Plugin Manager.

1

There is a workaround:
Change the search mode to Extended and replace "return-newline"s with \r\n
eg <?php\r\n $radio_buttons++;\r\n }\r\n?>
Problem is you need to know the white space (not shown above).

Maybe a regex could work?

0

Check out the TextFX menu option. That looks like it supports multiple line searching.

0

in the latest notepad++, simply select all the multiline text you want to search and press ctrl+f, it will automatically put the text to be searched in the search field formatted for multiline search.

1
  • 2
    What does "latest" mean? Please state the Notepad++ version number; latest is not a useful term.
    – AdrianHHH
    Commented Jun 9, 2023 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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