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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With