my vim show tab as --->, but does not show windows ^M character.
And , how substitute it in vim.
renew ============
I check my vimrc it is set fileformat=unix but when I open a dos file set ff is dos
0xD is the carriage return character. ^M happens to be the way vim displays 0xD (0x0D = 13, M is the 13th letter in the English alphabet). You can remove all the ^M characters by running the following: :%s/^M//g.
Basic Find and Replace In Vim, you can find and replace text using the :substitute ( :s ) command. To run commands in Vim, you must be in normal mode, the default mode when starting the editor. To go back to normal mode from any other mode, just press the 'Esc' key.
How can I remove ^M characters from text files? A. ^M are nothing more than carriage return, so it is easy to use the search and replace function of vim to remove them. That will do the job.
Note: Remember how to type control M characters in UNIX, just hold the control key and then press v and m to get the control-m character.
:e ++ff=unix
:setlocal ff=unix
:w
:e
Vim does show ^M except in one case: if the fileformat=dos then it will not show a trailing crlf.
You can find out which format (unix or dos) you have by typing :set
and you can get rid of the ^M in the crlf by just changing the format (:set fileformat=unix
) and then writing out the file.
If you have a ^M in the middle of the line, then you should be able to see it, even in a fileformat=dos
file, and you can pattern match it with \r
. (Oddly, the syntax for subsituting a newline is a \r
in the replacement part of the sub, so the way one changes ^M to ^N is by the not-at-all-a-noop :s/\r/\r/
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With