views:

50

answers:

3

I have a file with some non-printable characters that come up as ^C or ^B, I want to find and replace those characters, how do I go about doing that?

+3  A: 

Say you want to replace ^C with C:

:%s/^VC/C/g

where ^VC means type CTRL+VC.

The CTRL+V lets you enter control characters.

ars
A: 

You can use:

:%s/^C//g

To get the ^C hold the control key, press V then C (Both while holding the control key) and the ^C will appear. This will find all occurrences and replace them with nothing.

To remove both ^C and ^B you can do:

:%s/^C\|^B//g
codaddict
+2  A: 

You can use the CTRL-V prefix to enter them, or if they're not easily typeable, yank and insert them using CTRL-R ".

Piet Delport