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
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
vim is autodetecting the fileformat and switching modes to match (take a look at set ff
)
If you want to force it to open in a particular mode, toss a +ff=unix
(to show the ^M) or +ff=dos
in your command line to open it in that mode. If you're on a windows box, just try :e ++ff=unix
after opening the file.
If you're trying to just strip those characters out, you can open it in one mode, set the ff to what you want, and then save the file. Check out :h ff
for more details.
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/
.)
You can view all terminal linefeeds and carriage returns by enabling the list feature: :set list
.
ou can type them literally into match and substitution commands with ^V: e.g. to convert all ^M
s to CR
, you could do: :%s/^V^M/CR/g
(type a literal ^V followed by a literal ^M).