Line break characters for DOS and Linux

Source: Internet
Author: User
Tags sublime text

One, vim open window under the file appears ^m

First of all understand that DOS (Windows) created under the file line is ^m\$ (CRLF), and under Linux, only the \$ (LF) to do the break symbol;

(^m\$ actually has no \, except that the editor will make it a special symbol by default, so add a backslash)

This causes the ^m symbol to appear at the end of each line when Vim opens a DOS file

This symbol has a large effect, and if it is a shell script, it can cause the "program cannot execute" state

So how to solve it?

Ii. avoid ^m and solutions on each line

1. Can set the use of the editor to break the

As in sublime text, the option: "Default_line_ending": "System",

That changes with the system, under Windows is Crlf,unix is LF

2. Replacing symbols with commands

Vim command line status input:

:%s/[ctrl-v][enter]//g

The function of the ctrl-v is that the ENTER key is considered a special character, not the end of the vim command.

3. Using the Dos2unix command

such as: Dos2unix-k-n test.txt test.new.txt

-K, which preserves the original mtime time format of the file (does not update the last modified time of the file)

-N, which means preserving the original file and outputting the converted content to a new file

Note:-k-n cannot be written-kn, otherwise the execution is unsuccessful;

And, of course, the corresponding Unix2dos commands, which are used to convert each other.

Specific settings can be viewed through Dos2unix--help

Line break characters for DOS and Linux

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.