Invert regexp in vim
Posted
by Chris J
on Stack Overflow
See other posts from Stack Overflow
or by Chris J
Published on 2010-03-24T15:49:47Z
Indexed on
2010/03/24
23:33 UTC
Read the original article
Hit count: 347
There's a few "how do I invert a regexp" questions here on stackoverflow, but I can't find one for vim (if it does exist, by goggle-fu is lacking today).
In essence I want to match all non-printable characters and delete them. I could write a short script, or drop to a shell and use tr or something similar to delete, but a vim solution would be dandy :-)
Vim has the atom \p
to match printable characters, however trying to do this :s/[^\p]//g
to match the inverse failed and just left me with every 'p' in the file. I've seen the (?!xxx)
sequence in other questions, and vim seems to not recognise this sequence. I've not found seen an atom for non-printable chars.
In the interim, I'm going to drop to external tools, but if anyone's got any trick up their sleeve to do this, it'd be welcome :-)
Ta!
© Stack Overflow or respective owner