Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert the carriage return character in vim

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?

like image 701
Andrey Vlasovskikh Avatar asked Oct 18 '09 17:10

Andrey Vlasovskikh


People also ask

How do I show carriage returns in vim?

For non-Unix style line-endings, the carriage return character \r will be displayed explicitly in vim as ^M .

How do I create a new line character in vim?

Use \r instead of \n . Substituting by \n inserts a null character into the text. To get a newline, use \r . When searching for a newline, you'd still use \n , however.

How do I insert special characters in vi?

To insert, type Ctrl + K , followed by 1 and 2 .

How do you find the line break?

Press Ctrl+F. Word displays the Navigation task pane at the left side of the screen. In the box at the top of the Navigation pane, enter the text for which you want to search. To search for a paragraph mark, enter ^p; to search for a line break, enter ^l.


1 Answers

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.

like image 171
R Samuel Klatchko Avatar answered Oct 01 '22 12:10

R Samuel Klatchko