Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do we achieve the following using replace function in notepad++?

Transforming the following




I know ^ and $ (under Regular Expression) will let me access the beginning and end of the line and therefore I can put the single quotes at the extremes but then how do I append the lines thereafter? Also, I want to do everything (putting quotes and appending) in one go if possible.

Thank you very much for your help.

share|improve this question
up vote 3 down vote accepted
  1. Download the latest version, it includes regular expression fixes.

  2. Replace using the regular expression: (.*)[\r\n]* and turn it into '\1',

  3. Remove the last ,, it's not possible to do this inside the regular expression in Notepad++.

share|improve this answer
Thanks @Tom . Will you mind explaining a bit on your second step... – Stat-R Apr 11 '12 at 15:46
"fixes" link does not work. – Daniel Andersson Apr 11 '12 at 16:16
@Stat-R: I guess you figured out because of the replace, but it is basically like this: You go to the "replace" dialog and then tick "Regular Expression" and then fill in the two codes I gave you in the two boxes. – Tom Wijsman Apr 11 '12 at 17:17
@TomWijsman: "This page has been deleted"? Well, perhaps it shows that it is no longer an issue since the wiki page is no longer needed, if that is what you mean. – Daniel Andersson Apr 12 '12 at 6:22
@DanielAndersson: Now read the whole line under that. :D – Tom Wijsman Apr 12 '12 at 9:48

This solution is not a 100% percent solution, but it gets you most of the way there and is very simple. When I want to do this I use the "Extended" search mode on the replace dialog and use \r\n as the search term. In your case you would replace it with ','. That will get you to


Now you just need to fix the first and last elements manually.

share|improve this answer
I tried this before asking my question here but for some reason (??) this did not work for me. I am using NP++(6.1). – Stat-R Apr 11 '12 at 15:44
I just tried it on 6.1 and it worked fine. Make sure you file is using Windows line endings (View->Show Symbol->Show End of Line). You should see a CRLF at the end of each line. If you just see LF change your search term to \n. – heavyd Apr 11 '12 at 16:00
I saw CR and I used \r. It worked. Thanks @heavyd – Stat-R Apr 11 '12 at 16:22

You must log in to answer this question.

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