Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CR/LF in Emacs?

Tags:

emacs

How can I detect CR and/or LF in Emacs? Since I want to i-search CRLF, I prefer simpler way (e.g. no or less regex). Only relevant web page I've found is this but c-q c-j didn't work.

Thanks!

Environment) GNU Emacs 22.3.1 (i386-apple-darwin9.8.0, Carbon Version 1.6.0), but I also want to know how to do this on linux (Ubuntu).

like image 844
IsaacS Avatar asked Nov 14 '11 04:11

IsaacS


1 Answers

C-s to start i-search, then C-q C-j should work. Control-Q quotes the next character as a literal, and control-J is a literal linefeed ("LF" or newline).

If you're dealing with a file that has carriage returns (CRLF line endings), Emacs will automatically use a DOS buffer file coding system and convert them to just linefeeds when loaded, and reconvert them to CRLFs when saved. If you really want carriage returns in your buffer, run M-x revert-buffer-with-coding-system unix. Then carriage returns will be displayed in your buffer as ^M. In this case, you can search for them with C-s to start i-search, then C-q C-j C-q C-m.

like image 151
ataylor Avatar answered Oct 05 '22 05:10

ataylor