4

I am trying to replace in Notepad++ using the Replace module, the below paragraph in html (i have 30 html file, and need to replace the below in all of them)

<script type="text/javascript">
<!--
var slideInterval=20000;
var slideTransition=3500;
var slideArray=["/background1.jpg","background2.jpg"];
jQuery.fx.interval=33;
// -->
</script>

But Notepad++ doesn't let me replace unless it's a line instead of a paragraph, and if i put everything on one line to replace, i will have another problems to worry about in my html. I hope you have a work around on that.

Leb_Broth
  • 1,081
  • 1
  • 15
  • 32
  • If this is windows, new lines are `\r\n`. – Mr. Polywhirl Dec 22 '14 at 18:53
  • possible duplicate of [find multiple lines in notepad++](http://stackoverflow.com/questions/5489128/find-multiple-lines-in-notepad) – George Dec 22 '14 at 18:54
  • @George i know but it works only in one file. In the usual "Replace" i can replace in "All opened documents". This plugin doesn't have the "All opened documents". – Leb_Broth Dec 22 '14 at 19:05
  • If it works for one file, doing it 30 times shouldn't take long, since find/replace works quickly. – mbomb007 Dec 22 '14 at 19:14
  • yes @mbomb007 but iwant to do several operations 30 times. It's time consuming. – Leb_Broth Dec 22 '14 at 21:26
  • 1
    For this kind of replacement I like to use Geany, the result box is also very straightforward and useful to prevent mistakes – Frederik.L Dec 23 '14 at 00:28

2 Answers2

6

I found a good way to use a multi-line "find" or "replace". I just copy pasted the paragraph into the Ctrl+H "find" field, then brought another paragraph and pasted it into the "replace" field. Notepad++ will show a tabbed space that means a line break. And voila, you can "Replace in all open documents" with just a single click.

N.B.: the "copy" operation should be within Notepad++, otherwise it would paste only the first line in either fields.

Update: To be clearer about my answer, i found out that Notepad++ will let me only Paste once. That means, if i Copy a paragraph, i can paste it WITH its line break in the "find" field for example but if i paste it another time in the replace field, it will paste only the first line. Hence, no more than 1 "paste" operation is allowed into the Ctrl+H box in case i want to "paste" the line break.

So, in order for this to be done, first, i select any text i want and Ctrl+C on it, then, i go for the paragraph to be found, i just "Select" it and hit Ctrl+H: Notepad++ automatically shows the already selected text into the "find" field. Secondly, we "Paste" the text that's already in our clipboard into the "Replace" field. And the line breaks are here!

In brief: Select text --> Ctrl+C --> Select text --> Ctrl+H --> Ctrl+V in "replace field"

mbomb007
  • 3,788
  • 3
  • 39
  • 68
Leb_Broth
  • 1,081
  • 1
  • 15
  • 32
  • 1
    This doesn't work for me; it still only does the first line. You have to select the paragraph, then press Ctrl+H, and it auto-fills the text into the Find field. – mbomb007 Dec 22 '14 at 22:35
  • @mbomb007 exactly. It will be a one line pasted text into the find or replace field, along with the tabbed space inside it. – Leb_Broth Dec 22 '14 at 22:39
  • Not if you copy, deselect what you copied, then press Ctrl+H and paste. It didn't work. Of course it's *one line* in the field, but I only got the *first line* of text from the file. Not the whole paragraph. Pasting doesn't work. You have to merely select the paragraph, then press Ctrl+H. – mbomb007 Dec 22 '14 at 22:41
  • 1
    @mbomb007 i just copy anything from an opened HTML let's say in Notepad++, then CNTRL+H, then i paste wherever i want. And it works. – Leb_Broth Dec 22 '14 at 22:44
0

I think I found a guide that describes what you're looking for. The author has examples and the results, and some multi-line replacements are included. You should be able to extrapolate what he does over multiple files by clicking "Replace All in All Opened Documents".

http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html

mbomb007
  • 3,788
  • 3
  • 39
  • 68