Insert the carriage return character in vim

UnixVimSpecial Characters

Unix Problem Overview


I'm editing a network protocol frame stored a file in Unix (\n newlines). I need to insert the carriage return character (U+000D aka \r). When I try to paste it from the clipboard ("+p) or type it using Ctrl+Shift+u-000d, the linefeed is inserted (U+000A).

What is the right way to do it?

Unix Solutions


Solution 1 - Unix

Type: ctrl-v ctrl-m

On Windows Use: ctrl-q ctrl-m

Ctrl-V tells vi that the next character typed should be inserted literally and ctrl-m is the keystroke for a carriage return.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndrey VlasovskikhView Question on Stackoverflow
Solution 1 - UnixR Samuel KlatchkoView Answer on Stackoverflow