Vim remove or replace ^ m character replace or replace ^ M character use vi in Linux to view some text files created in Windows, sometimes it will find some ^ M at the end of the line. There are several methods for processing. 1. use the dos2unix command. This tool is included in the general distribution version (if there is no... vim remove or replace ^ m character replace or replace ^ M character in Linux use vi to view some text files created in Windows, sometimes you will find some "^ M" at the end of the row ". There are several methods for processing. 1. use the dos2unix command. This tool is included in the general distribution version (if not, you can download the tool based on the following connection). It is very convenient to use: $ dos2unix myfile.txt the command above will remove the ^ M at the end of the line. 2. use the replacement function of vi. Start vi and enter the command mode. enter the following command: % s/^ M $ // g # Remove ^ M at the end of the line. : % S/^ M // g # Remove All ^ M. : % S/^ M/[ctrl-v] + [enter]/g # replace ^ M with the carriage return. : % S/^ M/\ r/g # replace ^ M with the carriage return. 3. use the sed command. Similar to vi usage: $ sed-e's/^ M/\ n/g' myfile.txt note: Here "^ M" is generated using the CTRL-V CTRL-M, instead of directly typing "^ M"
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.