简体   繁体   English

有没有办法在 Notepad++ 中替换整个段落

[英]Is there a way to replace a whole paragraph in Notepad++

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)我正在尝试使用 Replace 模块在 Notepad++ 中替换 html 中的以下段落(我有 30 个 html 文件,需要在所有文件中替换以下内容)

<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.但是 Notepad++ 不允许我替换,除非它是一行而不是段落,如果我将所有内容都放在一行上进行替换,那么我的 html 中将有另一个问题需要担心。 I hope you have a work around on that.我希望你能解决这个问题。

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.我只是将段落复制粘贴到Ctrl+H “查找”字段中,然后带来另一个段落并将其粘贴到“替换”字段中。 Notepad++ will show a tabbed space that means a line break. Notepad++ 将显示一个选项卡式空格,表示换行。 And voila, you can "Replace in all open documents" with just a single click.瞧,您只需单击一下即可“替换所有打开的文档”。

NB: the "copy" operation should be within Notepad++, otherwise it would paste only the first line in either fields.注意:“复制”操作应该在 Notepad++ 中,否则它只会粘贴任一字段中的第一行。

Update: To be clearer about my answer, i found out that Notepad++ will let me only Paste once.更新:为了更清楚地说明我的答案,我发现 Notepad++ 只会让我粘贴一次。 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.因此,如果我想“粘贴”换行符, Ctrl+H框中不允许进行超过 1 次“粘贴”操作。

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.所以,为了做到这一点,首先,我选择我想要的任何文本并在上面Ctrl+C ,然后,我去寻找要找到的段落,我只是“选择”它并按Ctrl+H :Notepad++ 自动在“查找”字段中显示已选择的文本。 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"简而言之:在“替换字段”中选择文本 --> Ctrl+C --> 选择文本 --> Ctrl+H --> Ctrl+V

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 http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM