I've just created a Vim function to replace Windows linebreaks with Unix ones. Now I want to be able to type :linebreak and have it run. Here's my first attempt:
function UseUnixLineBreaks()
:%s/^M/\r/g
endfunction
cmap linebreak :call UseUnixLineBreaks()<CR>
(By the way, that ^M is a control character - type it with Ctrl+v Ctrl+m)
When I try to run this by typing :linebreak, it does run, but it behaves oddly: each letter of the command appears in sequence, erasing the previous one. For example, I see :l, then :i, then :n, etc. When I type the last letter, it runs immediately.
I want the whole command to appear, so that I can see I've typed it correctly, then press enter to run it.
How can I do this?