1

how do you replace multiple lines of code in Kate?

The following is the original text:

<div id="image">
<br style="clear: left"/>
<br style="clear: left"/>
<br style="clear: left"/>
<!-- Begin logo -->
...
<!-- End logo -->
</div>

This is the text that I would like to have:

<div id="image">
<!-- Begin logo -->
...
<!-- End logo -->
</div>
  • kate's search and replace only works on a single line. – jordanm Jan 2 '15 at 15:11
2

Through Ctrl+R you switch into the search & replace mode. In the bar on the bottom, you first have to select as Mode either Escape sequences or Regular expressions.

For instance, if you choose Escape sequences, click the right mouse button on the search field. A context menu appears with an item called Add, listing some valid escape sequences, among which you will find \n. The same apples for the replace line edit. The context menu is also available in the Regular expressions mode.

  • Just to clarify: an explicit \n is necessary even when other constructs might ordinarily match line breaks: <font[^>]*>(([^<]|\n)*)</font> and <font[^>]*>([^<]*)</font> behave differently: the former will match across line breaks and the latter does not. – Oliver Coleman Sep 14 '17 at 22:56
0

Using \n to represent a newline works in gedit and most other editors I've tried, it should work in Kate too, does it?

Even selecting 2 lines and "dragging" them, or copy the 2 lines together and paste into gedit's search box copied the text with the \n in the correct spot.

Kate's webpage advertises "support for multiline search & replace"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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