Convert unix and dos formats in vim

Source: Internet
Author: User
The unix and dos formats in vim were converted a long time ago. the old-fashioned telex typewriter used two characters to create a new line. One character moves the slide frame back to the first place (called carriage return, & lt; CR & gt;), and the other character moves a line (called line feed, & lt; LF & gt;) on the paper ;). After the advent of computers, the memory was once very expensive to convert unix and dos formats in vim a long time ago, the old telex typewriter used two characters to create a new line. One character moves the slide frame back to the first place (called carriage return, ), Another character moves a line (called line feed, ). 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 they can use A character to indicate the end of a line. Apple developers have defined . Those who develop MS-DOS (and Microsoft Windows) decide to keep old-fashioned . It means that if you try to move a file from one system to another, you have trouble with line breaks. If you try to edit a file in MS-DOS format with the good Vi of the past, you will find a ^ M character at the end of each line. (^ M is ). The Vim editor can automatically identify different file formats and complete the tasks without worrying about them. The 'fileformats' option contains various formats. Vim tries to define various formats when editing a new file. For example, the following command tells Vim to try the UNIX format first, and then try the MS-DOS format: set fileformats = unix, dos when editing a file, you will notice that the message provided by Vim contains the format used by the file. If you are editing a local file (the file format you edited is the same as that of the system used), you will not see any format name. Therefore, editing a Unix file on a Unix system does not produce any information about the format. But if you edit a dos file, Vim will notify you: "/tmp/test" [dos] 3L, 71C you can use the 'fileformat' option to convert a file from one format to another. For example, if you have a MS-DOS file named README. TXT, you need to convert it to UNIX format. Edit the file in MS-DOS format: vim README. TXTVim will recognize that it is a dos format file. Now, the file format is changed to UNIX: set fileformat = unix: write or: set ff = unix, and the file is saved in Unix format.
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.