vim often encounter the phenomenon of abnormal Chinese display, which is the legendary garbled. A search, found a solution in http://www.chinalinuxpub.com/bbs/showthread.php?t=45475. But the GBK code is normal, and the UTF8 is wrong. So a little bit changed. Create a. vimrc file in the user directory join set fileencodings=utf-8,gb2312,gbk,gb18030 set Termencoding=utf-8 set Fileformats=unix set encoding= The PRC fileencodings utf-8 to be in front.
This will show the Chinese as normal. With Pietty, can be completely normal display, editing Chinese.
Several methods of removing ^m
1. Cat Filename1 | Tr-d "\ r" > NewFile
2. Sed-e "s/^v^m//" filename > OutputFileName
3, vi: Open file with VI
1. Press the ESC key
2. Input:%s/^m//g
Make sure that ^m is using "Ctrl-v ctrl-m" instead of literally ^m. This regular will replace all carriage returns before the ^m is empty ($ is to ensure that ^m appear at the end of the line) 4, some Linux version has Dos2unix program, can be used to eliminate ^m
5, with Vim
Input: Set Notextmode
Unfortunately, after the above processing, ^m does not exist, but the line is not successful. Everything was on the line and looked very laborious. This means that the file is missing "\ n" when it is processed and can be added at the time of substitution:
Cat FileName | TR "\ r" "\ n" > NewFile
Vi/vim display Chinese characters and remove the ^m method