2

I want to remove a new line created after each name in a chat log file. Example:

Person1:[space]
their message
Person2:[space]
their message

So I set it to extended search in Find & Replace, and I search for the string:

: \r

And set it to replace with:

:[space]

It finds the instances of this that I'm looking for, but for some reason it doesn't bump the text back from the new line when I replace - and it says it's been successfully replaced. I tried removing the space from the replacement text, and it took the spaces out, but still didn't bump the text up a line.

Any suggestions?

  • There is no guarantee that the last symbols of user's message is not :[space]. But I do not see the way to distinguish is this substring the tail of the header or the tail of the message... Is the PersonN:[space] a real header content or it looks like John:[space]? – Akina Jul 13 '18 at 4:27
  • BecauseICanTBH - See Accepting an Answer to ensure you understand how that works for the solution you find for any answers that help you resolve your problem by simply checking the little gray check box to the upper left side of the answer that resolves your problem assuming one does and turn it green to show it's the answer you accepted since that's how that is supposed to work; you ask a question, you get answers, and if you get an answer that works for your needs, you simply accept that answer. – Pimp Juice IT Jul 14 '18 at 17:53
3

Find : \r\n and replace with :[space]

You need to find the carriage return (CR) and line feed (LF).

| improve this answer | |
2
  • Ctrl+H
  • Find what: :\h+\R
  • Replace with: : (a semicolon followed by a space)
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

:       : a semicolon
\h+     : 1 or more horizontal spaces
\R      : any kind of linebreak (ie. \n, \r or \r\n)

Result for given example:

Person1: their message
Person2: their message    
| improve this answer | |
0

As already mentioned in the other answer, you need to change \r to \r\n. This because Windows uses a combination of Carriage Return (CR in Notepad++ or \r) and Line Feed (LF in Notepad++ or \n) to signal new lines.

Regarding your issue, Notepad++ treats the replacement of \r literally (so your final replacement is actually [space] \n). And since other operating systems use either a single \n (Linux) or \r (the MacOS default, if I am not mistaken) for "newline" characters, Notepad++ treats them that way as well (i.e. represents them as line breaks, hence no "bumping").

Notes

  • If you ever need to see formatting characters (Tabs, Spaces, End of Line) you can use View > Show Symbol to see them.

  • Make sure to have Extended or Regular expression marked in Search Mode when replacing.

| improve this answer | |

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.