Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I have some text I want to edit using Notepad++.

The text follows a pattern such as test 1 - test1, test 2 - test2, test 3 - test3 and so on, one per line. I would like to 'cut' all the characters on every line after the '-' character/symbol. I need everything that has been cut to be put in clipboard so i can paste it elsewhere. (If the prefix can not be put in the clipboard, then simply how to delete all characters after the '- ' would suffice).

By search\replace in notepad using -.* will remove everything after the '-'. I need to know how to cut and copy it rather. If I can figure out how to remove everything BEFORE the '-', like the above does, I can just copy it all. Any ideas? Would be much easier.

share|improve this question
Please explain the down vote of this question? It's an issue I have and need an answer to. It does not exist anywhere on the site, and it's asked straight forward. – user2526699 Aug 29 '13 at 1:20
It was mostly wording and formatting issues. The edited question is fine, so I removed my downvote. – That Brazilian Guy Aug 29 '13 at 2:52
up vote 5 down vote accepted

To get the prefixes (the text before the dashes), press Ctrl+H and fill out the fields as follows:

enter image description here

To get the suffixes (the text after the dashes), press Ctrl+H and fill out the fields as follows:

enter image description here

This breaks if there are any dashes in either the prefix or the suffix.

If you need to get both separately, just capture the results from the first replace to a different file (or the clipboard), then press Ctrl+z and perform the second replace.

If you need to include the dash and/or spaces, you can add them as needed in the "Replace with :" text box before or after the replacement placeholder.

share|improve this answer
+1 helped me remove comments out of an SQL file. saved me hours of manual finding and deleting. awesome. – jmcg Dec 18 '15 at 3:41

This is not exactly what you're looking for since it does not use Notepad++, but if you're open to using MS Excel, it'll help with getting what you need on the clipboard in one go.

Open the file in MS Excel and follow the procedure below:

  1. Choose the option 'Delimited' enter image description here

  2. Set the delimiter as - enter image description here

  3. Click 'Finish' and you're done! enter image description here

share|improve this answer
Creative, but off-topic for the question, since this pertains to Notepad++. – allquixotic Aug 29 '13 at 3:08

To remove everything before - and the symbol itself use the regexp [^\-\n\r]+- (non-dashes and linebreaks followed by dash).

Replace found text by empty string and select what is left.

share|improve this answer

Just use block select mode in Notepad++! Hold Alt and highlight text in a block.

share|improve this answer
I tried that nothing happened for me. – user2526699 Aug 29 '13 at 1:25
Ok I see what you mean. thats a nice trick actually. But Not all of my lines are the same length so it wont work. – user2526699 Aug 29 '13 at 1:26
It will, just select a block around all the text, it won't add extra spaces. :) EDIT: Sorry, I thought you meant you had just a list like the test you showed, it would work if they started inline and finished at different places. – abc_harold Aug 29 '13 at 1:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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