Hi I am trying to add Control M character in a text file using Putty. I tried to do Ctrl-v Ctrl-M but as soon as I do this it goes out of putty to my desktop home.Can anyone please tell me how to add Ctrl M character in a file
Asked
Active
Viewed 2,761 times
3 Answers
3
The easiest way would probably be to use the unix2dos
utility:
$ unix2dos myfile.txt

Mureinik
- 297,002
- 52
- 306
- 350
-
This will add control m character in the file? – Pramod Bhat Mar 19 '20 at 11:48
-
@PramodBhat Yes, it will. At least it did for me on RHEL7. – Bence Kaulics Aug 29 '22 at 13:38
3
In vim
in the insert mode and type CTRL-v CTRL-m.

RishabhHardas
- 495
- 1
- 5
- 25
-
This is what I tried,as soon as I do this it comes back to homepage – Pramod Bhat Mar 19 '20 at 11:56
-
You can enter unicode characters in vim. Press and type CTRL-v and then the hex code of the character – RishabhHardas Mar 19 '20 at 12:02
-
Hey I pressed Ctrl V followed by enter and it worked.but how?? Any idea? – Pramod Bhat Mar 19 '20 at 12:08
-
1Windows-based text editors will have a special carriage return character (CR+LF) at the end of lines to denote a line return or newline, which will be displayed incorrectly in Linux (^M). – RishabhHardas Mar 19 '20 at 12:09
1
In Vim, in the insert mode, Ctrl-V x##, where ## is the hex code of the character. In case of Ctrl-M the combination is Ctrl-V x0d. You can see the hex value of a character under cursor if you type :as command.

xxor
- 94
- 3