There are two cases in which the open file appears with the ^m symbol:
1. Vim is configured as Fileformat=unix, and the files you open are in DOS format. The Unix-formatted newline character is 0A (ASCII) and the newline character in <lf>,dos format is 0D 0A (that is, <CR><LF>),<cr> is actually displayed as ^m. Here is a detailed explanation:
DOS, Mac, and UNIX-formatted files
Recall the prehistoric history of the computer, when the typewriter used two characters to start a new line.
The first is a character command to move the printhead back to the start position (carriage return,<cr>), and then another word
The,<lf> command controls the forward line (paper feed).
At the beginning of the computer, storage devices were very expensive. And then someone suggested that there was no need
Use two characters to indicate the end of a line. The Unix family decided to use only one character of the paper into <line
Feed> to represent the end of the line. The people from the Apple camp put the carriage return <CR> as the label for the line change.
Quasi -. MS-DOS (and Microsoft's Windows) still decided to follow the old carriage return line <CR><LF> Pass
Ec
This also means that if you move files from one system to another, you will encounter
To issues related to line breaks. The VIM Editor can recognize these files in different formats.
You can specify the set of formats you want Vim to recognize automatically in the ' fileformats ' option.
Compliance The following command allows vim to automatically recognize the UNIX format and MS-DOS format:
: Set Fileformats=unix,dos
Put this sentence in the _VIMRC, the general situation will be OK.
2. Your text has both a UNIX line break and a DOS newline, so vim will think you are opening UNIX, so those DOS line breaks will have annoying ^m. However, this is not a common situation. The approach is:
1) If your VIM version is greater than 7.1, and you want to display and save with DOS, the following statement:
: E ++ff=dos
2) If your VIM version is less than or equal to 7.1, and you want to display and save the article in DOS format, the following statement:
: Set Ff=dos
:%s/\r\+$//e
3) If your VIM version is less than or equal to 7.1, and you want to display and save the article in UNIX format, the following statement:
: Set Ff=unix
:%s/\r\+$//e
Remove Vim ^m symbol