Delete ^ M from text under VI

Source: Internet
Author: User
A long time before carriage return and line feed, the old-fashioned telex typewriter used two characters to start a new line. One character moves the slide frame back to the first place (called a carriage return, with an ASCII code of 0 D), and the other character moves a line (called line feed, with an ASCII code of 0 A) on the paper ). After the advent of the computer, the memory used to be very powerful...
A long time before carriage return and line feed, the old-fashioned telex typewriter used two characters to start a new line. One character moves the slide frame back to the first place (called a carriage return, with an ASCII code of 0 D), and the other character moves a line (called line feed, with an ASCII code of 0 A) on the paper ). After the advent of computers, memory was once very expensive. Some people think that there is no need to use two characters to represent the end of the line. UNIX developers decide that they can use a single character to indicate the end of a line. Linux follows Unix, too. Apple developers have defined the usage. those guys who develop MS-DOS and Windows decide to keep old-fashioned. the three line tail formats are as follows: unix: \ n dos: \ r \ n mac: \ r, which means that if you try to move a file from one system to another, then you have trouble with line breaks. Because MS-DOS and Windows are carriage return + line feed to express line feed, so in Linux use Vim to view the code written in Windows, line after the "^ M" symbol. Www.2cto.com solves this problem in Vim. in Vim, you can use the replacement function to delete "^ M" and enter the following command line to replace it :: % s/^ M // g note: the "^ M" character in the above command line is not "^" and then "M ", it is generated by the "Ctrl + v" and "Ctrl + M" keys, or Ctrl + v, and then press Enter. Or run the following command: % s/\ r // g.
Author ltl3884
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.