1

I accidentally used the wrong-sided slash when trying to write the Newline (Line Feed) escape character, in C.

When trying to replace it in gedit:

pre-replacement

I get this outcome:

post-replacement

Clearly gedit (version 3.18.3, running on my Ubuntu 16.04) is treating the New Line escape character as an excuse to actually spit out a new line.

Is this a known bug? It's an edge case, and I probably would have never even thought about it if I could write an escape character properly, but still - it made me curious as to what can be done to solve it.

I've tried parentheses, commas, one quotemark, two quotemarks.... no cigar.

The code itself is just an overly-tedious switch exercise from a book, LCTHW by Zed A. Shaw.

2 Answers 2

4

Gedit simply interprets the \n as newline character, which is correct and useful in my opinion, because it allows you to replace something with real line breaks.

To stop that and replace something with \n literally, you have to escape the backslash with another backslash and type \\n instead in the "Replace with" text field.

3

Use \\n instead of \n in Replace with field

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .