I've run into the problem mentioned here, but in a context in which I don't have an easy alternative that I can think of.
I'm trying to add a mapping to fix bad newline characters in a file. I would generally type:
:%s/^M//g to remove all of the
^M characters. My mapping attempt to do this (and save) is as follows:
nnoremap <Leader>fix :%s/^M//g<Bar>w<CR>
The problem with my mapping is that the
^M gets automatically converted to
<CR> and the mapping breaks, of course. I have also tried:
nnoremap <Leader>fix :%s/<c-v><c-m>//g<Bar>w<CR>
...and that fails as well.
I've noticed that if I leave off the
<CR> at the end to debug the mapping, I get
//g|w as the only thing on the command prompt. Ideally, this would be
%s/^M//g|w to achieve the desired behavior.