Sublime Forum

Search & Replace in an XML file adds an unwanted return character

#1

If I want to search for and replace characters within an XML Element, an additional (unwanted) line feed / carriage return is inserted.

Example

nb: the characters -[ and ]- replace the “<” and “>” characters - this website otherwise processes the XML example!

The existing element “-[MinDaysToExpiry]-7-[/MinDaysToExpiry]-” occurs 22 times in an XML document.

I want to replace it with “-[MinDaysToExpiry]-6-[/MinDaysToExpiry]-”

But a carriage return/line feed is always inserted at the end of the replacement string so I get:

 "-[MinDaysToExpiry]-6

-[/MinDaysToExpiry]-"

How do I stop sublimetext from inserting the unwanted carriage return?

0 Likes

#2

This is somewhat an awkward behavior which I never seem happening. Alternatively, you can try:

  1. Selecting with the mouse, the words -[MinDaysToExpiry]-7-[/MinDaysToExpiry]- and press Alt+F3
  2. Press the Left Arrow
  3. Press the Right Arrow until you got the 7 digit and delete it and type 6

This will create multiple cursors/carets and will edit all occurrences of the text at once. The only downside of this approach is if the file has some Giga Bytes of size, then, Sublime Text will hang for several seconds each keystroke you change:

0 Likes