Patrick Klitzke
Patrick Klitzke

Reputation: 1559

Vim: Delete everything in a line but the numbers

I want to delete everything in a line but numbers. I have a line that looks like this:

a b c d 12 k f h 10

I want the output to be

1210

I tried

:%s/\d+\@!//

but nothing happens, although all the text that should be deleted will be marked.

Upvotes: 2

Views: 771

Answers (1)

Jens
Jens

Reputation: 69450

Try

:%s/\D//g

It should delete all non digits.

Upvotes: 8

Related Questions