Remove the ^ M symbol displayed in the file
Remove the ^ M symbol background displayed in the file
For files edited under windows, the ^ M symbol sometimes appears when opened with vim under Linux.
Principle
The contents of this section are referred to [1]
Vim is configured as fileformat=unix, and the files you open are in dos format. The newline character in unix format is 0A (ascii code), that is, the newline character in dos format is 0D 0A (that is,), which is actually displayed as ^ M.
Think back to the prehistory of computers, when typewriters used two characters to start a new line. First, a character command moves the print head back to the start position (enter,), and then another character command controls the feed line (feed,).
In the early days of computers, storage devices were very expensive. So it is suggested that there is no need to use two characters to indicate the end of a line:
The UNIX family decided to use only one feed character to represent the end of the line. People from Apple's mac camp use carriage return as the standard for changing lines. MS-DOS (and Microsoft's Windows) still decided to follow the old tradition of carriage return.
This also means that if you move files from one system to another, you will encounter problems associated with line breaks.
Solution method
Today, I stumbled upon a good way to remove ^ M:
Specify the filename: sed-I "s /\ srabbit plaza g" filename all the files in the current directory: sed-I "sr /\ srabbit racket placca g" `ls`