How to enter ^M in vi

Maybe you sometimes wondered how to enter ^M (Control-M, STRG-M in German) in searches or substitutions in vi. Once you know, it is easy: enter ^V^M and you won’t end up as if you entered RETURN. So to remove all ^Ms in in a document which was originally edited on a DOS platform, you can use this command:


The ^V will disappear immediately when you type the ^M – but the ^M will stay there 🙂

Leave a Reply