0

I have a *.txt file with 10,000 lines. The lines are E-Mail and password divided by a ":", so like

E-Mail:Password

I want to delete the E-Mail addresses on every single line at once, so I end up with the passwords only. How can I do that?

Thanks in advance.

1
  • 1
    If this is for later processing, awk may be a better tool for automation.
    – D. Ben Knoble
    Commented Jan 20, 2019 at 21:53

2 Answers 2

2

Try:

:%s/^[^:]*://

Matches from the start of the line all not-: until the first : and replaces them with nothing.

3
  • I am using GVIM. When i open the text file and do what you said, it just starts editing the text file. Would you be so kind and could give me like a step by step explation? I'm kinda overwhelmed by this software and don't want to spend 5 hours reading tutorials. Might as well go ahead then and do it by hand, would be faster probably! :D
    – Marcel
    Commented Jan 20, 2019 at 21:30
  • @Marcel This particular command should start with a colon : so that it runs a command rather than "normal" keys. I would recommend starting with vimtutor to get a basic idea of the different modes, and how to exit and whatnot.
    – DJMcMayhem
    Commented Jan 20, 2019 at 21:40
  • @Marcel Added leading colon.
    – Ralf
    Commented Jan 21, 2019 at 5:14
1

Ralf's answer is great. Here's another way you could do it as well:

:%norm df:

:%norm means type the following keys on every line. df: means delete until your find the next ':'.

3
  • That worked, but now i have all those : at the beginning. I have to get rid of them as well, but the following character is different in every line.
    – Marcel
    Commented Jan 20, 2019 at 21:40
  • @Marcel Sorry, my bad. See my edit.
    – DJMcMayhem
    Commented Jan 20, 2019 at 21:41
  • Wow, thanks a lot! Been sitting here since 2 hours scratching my head. Thank you very much!
    – Marcel
    Commented Jan 20, 2019 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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