I've got a text file that has lines delimited by <CTRL>B and <CTRL>C.
How do I search and/or replace control characters?
Depends on whether you want to replace all of them with the same
thing:
:%s/[[:cntrl:]]/XXX/g
Or, if you want to treat them specifically, you can use their
hex-values like:
:%s/\%x02/"control+b"/g
:%s/\%x01/"control+a"/g
Alternatively, you can insert them into your search criteria by
prefixing them with control+V, so you'd enter "colon percent ess
<divider> control+V control+A <divider> replacement text
<divider> gee" which would come out looking like
:%s/^A/replacement text/g
where the "^A" is highlighted as a control-character.
More info can be found at:
:help [:cntrl:]
:help /\%x
:help c_cntrl-v
(note the caveats that control+V may be remapped to control+Q if
you've sourced mswin.vim)
Hope this helps,
-tim