You could use a simple function like this to substitute each occurrence (on the current line) of ^M
, ^[
, etc. with their replacements. You can add extra entries to the replacements
dictionary as you find you need them.
function! ReplaceWeirdCharacters()
let replacements = {
\ "\<C-[>": '<Esc>',
\ "\<C-M>": '<CR>',
\ "\u80kb": '<BS>'
\}
for [a, b] in items(replacements)
execute "s/" . a . "/" . b . "/ge"
endfor
endfunction
nnoremap <leader>rwc :call ReplaceWeirdCharacters()<CR>