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?
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/
(source: phdesign.com.au)
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...
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:
The easiest one: Go to menu option Plugins > Plugin Manager > Show Plugin Manager, scroll the available plugin list to "TextFX Characters" and install it.
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
then extract its contents (don't just copy zip file) to theTextFX.v0.26.unicode.bin.zip
\plugins
subfolder of the Notepad++ Install Folder
After restarting Notepad++ you'll see the menu entry TextFX.
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++
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.
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.
I found the following thread on a related subject: Multiline Regular Expression search and replace!
Recommend that you try out CTRL + R!
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
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.
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?
Check out the TextFX menu option. That looks like it supports multiple line searching.
精彩评论