Vim open file with ^m at the end of each line

Source: Internet
Author: User

Why does ^m appear?
1. 在windows下的文本文件的每一行结尾,都有一个回车(‘\n‘)和换行(‘\r‘)2. 在linux下的文本文件的每一行结尾,只有一个回车(‘\n‘);3. 而在linux下打开windows编辑过的文件,就会在行末尾显示^M; 4. 注:^M在vim中为crtl+M
How to fix? Method one in the VIM command line input
:%s/\r//
%s/^M//#注意此处^M为crtl+M,不是字面上的^M
Method two with Dos2unix
dos2unix filename
Method three SED
sed ‘s/\r//‘ filename -i
Method four Batch Processing
find -mtime 0 -print0 |xargs -0 sed -i ‘s/\r//‘find -mtime 0 -print0 |xargs -0 dos2unix
Command parsing find
    1. -time        1. -atime  访问时间(access)        2. -mtime 修改时间(modify)        3. time的时间单位为day                 1. -mtime 0   表示今天之内修改的文件                2. -mtime -3  三天以内                3. -mtime +3 三天以外               2.  find默认打印输出为-print(换行显示), -print0 为不换行输出
xarg-0
    用\0作为分隔符,分隔字符串
Do the following

Vim open file with ^m at the end of each line

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.