Ex command :v to the rescue!
:v/pattern/d
Using :g! will give you the same result as using :v.
:g finds lines that do match a pattern.
I had a large list of locations. I wanted to keep only the locations containing hyphens and delete the rest so I used this: :v/-/d
:v – find lines not matching your pattern
d – delete matches
Recently Loved Articles
- 2013 CES: Press Conference Slides – Imgur – Can’t wait!
- Naming things | Ross Duggan – Great article about naming software
- Programmer Secretly Outsources His Job to China So He Can Get Paid to Screw Around on Reddit | Betabeat
- Chrome Web Store – Page Turner – My first published Chrome Extension :D
- Ebook Glue Transforms Blogs Into Ebooks – Looks good. Try it.
- Indentation With Spaces Considered Harmful – Using tabs means everyone can use their preferred tab widths in their IDEs.
- The Javascript Show – Good JavaScript podcast I found.
- Vimulator – Helpful for people learning Vim.
- Drugs at work – YouTube – haha!
- 10 Reasons Why 2013 Will Be The Year You Quit Your Job | TechCrunch – Good read
Dan Herbert
Nice!
I always forget about that one. I usually do (for your scenario with hyphens):
:%!grep -v –
n8kowald
Grep with an invert-match, nice!
I'll remember this flag for future greps :)