Stealth Mode

Carriage Return Notepad++

Posted by: admin on: May 2, 2012

http://superuser.com/questions/34451/notepad-find-and-replace-string-with-a-new-line

 

Consider the scenario where you have a specific string that you want to find-and-replace. You want to replace it with a new string that contains a newline command.

abc123 xyz456-blah

fsafd23 xyz456-green

89hjkf23 xyz456-red

afdsa23 xyz456-yellow

abaac123 xyz456-orange

In the scenario above, I’d like to find “ xyz” and replace the space with a carriage return/newline.

The results would look like:

abc123

xyz456-blah

fsafd23

xyz456-green

89hjkf23

xyz456-red

etc…

Question: How would you most easily achieve this using Notepad++. Are there any other tools that you’d suggest to easily perform this command?

asked Sep 2 ’09 at 17:57
pcampbell
5372923
62% accept rate
feedback

5 Answers

Notepad++ will do just fine.

search string : xyz456 (note the space in front of xyz456)

replace string : \r\nxyz456

“\r\n” is the code for carriage-return in Notepad++.

answered Sep 2 ’09 at 18:02
caliban
10.8k21844
1
\r\n = Windows newline syntax. However, for everything other than plain old notepad, it will accept just \n for a newline (which is also more conventional). – Macha Sep 2 ’09 at 18:09
Your phrase “more conventional” is misleading. “\r\n” is the standard on Windows. It’s just that a lot of editors and IDEs happen to recognize the Unix/Linux standard line ending “\n” and display the document accordingly. There’s nothing about “\n” that makes it more conventional. – Brian Lacy Nov 12 ’10 at 20:44
To be honest, the Win/DOS version makes more sense to me. “\r” means “Carriage Return, or ‘Return the carriage/cursor to the beginning of the line’” and “\n” means “Advance the carriage/cursor forward one line”. Of course, Unix came 20 years before, so I guess in that sense it is Microsoft who broke the standard. – Brian Lacy Nov 12 ’10 at 20:49
2
this wont work unless you set the search mode, as specified in the other answer:superuser.com/questions/34451/… – codeulike Aug 19 ’11 at 15:49
feedback

In Notepad++, it’s very easy…

  • Find: xyz
  • Replace with: \n

 

  • Search Mode: Extended (\n, \t, etc)

The trick is to set the search mode.

answered Sep 2 ’09 at 18:01
th3dude
5,82521541
1
This answer worked for me, the accepted did not. Ver 5.8.6 – bdwakefield May 19 ’11 at 23:53
Yes same here the accepted answer did not specify using the extended mode.. – Andy Nov 18 ’11 at 8:17
feedback

In the “Replace” dialog, make sure that under Search Mode you have “Extended” selected. Then type in the find box enter “xyz” and replace with “\n”.

answered Sep 2 ’09 at 18:01
tj111
1,3911717
feedback

I cheat a bit when S&Ring characters that I can’t type directly into the text fields (e.g. tabs and newlines). Find somewhere in the document which already has that character, then copy it, and paste it into the replace field.

So in your example, start at the very start of one line, click, drag to the very end of the preceeding line, copy that, and paste it into the Replace dialog.

answered Sep 2 ’09 at 17:59
Macha
2,12231947
Care to explain why you downvoted this, random user? – Macha Sep 2 ’09 at 18:03
+1 to counter random… – ralf.w. Mar 17 ’11 at 8:32
feedback

For Notepad++, change the search mode to Extended then in the Replace with field use \n.

answered Sep 2 ’09 at 18:02
dlux
9431923
feedback


Your Answer

log in
or



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

Tags: ,

Order Text Alphabetically in Notepad++

Posted by: admin on: May 2, 2012

 

 

Tracker: Feature Requests

5sort alphabetically the lines – ID: 2972061
Last Update: Comment added ( BennyB )
I would like to propose two functions for Notepad + + in Line operations:
A function to sort alphabetically the lines of the file in order and reverse order.
A function to remove duplicate lines.

morfeust@gmail.com


Nobody/Anonymous ( nobody ) – 2010-03-17 09:56:29 PDT

5

Open

None

Nobody/Anonymous

None

None

Public

Comments ( 4 )

Date: 2012-03-07 02:26:37 PST
Sender: BennyB

Just to help people who find this:

Menu Item TextFX
TextFX Tools
Sort Lines case sensitive (at column)

There is under the same menu item case insensitive and a toggle for
ascending / descending.
This will sort the selected lines.

Date: 2011-05-01 22:07:31 PDT
Sender: hcbnone

idea torrent : Idea #384

is in TextFX but seems hidden, see idea, above.

Date: 2011-05-01 21:27:18 PDT
Sender: hcbnone

i logged in to ask for this too but more notibly the second item that is
not in the title. i cannot find either one in the textFX

Date: 2010-03-17 10:06:13 PDT
Sender: nobody

have u checked TextFx plugin /Menu TextFx, It may solve your problem

Attached File

Change

 

 

Tags: