my vim show tab as --->, but does not show windows ^M character.
我的vim显示选项卡- - - >,但不会显示窗口^字符。
And , how substitute it in vim.
用vim代替它。
renew ============
更新= = = = = = = = = = = =
I check my vimrc it is set fileformat=unix but when I open a dos file set ff is dos
我检查了我的vimrc,它是set fileformat=unix,但是当我打开dos文件时,ff是dos。
4 个解决方案
#1
51
Vim does show ^M except in one case: if the fileformat=dos then it will not show a trailing crlf.
Vim ^ M除了显示了一个例子:如果fileformat = dos末尾就不会显示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.
你可以找出哪些格式(unix或dos)你有通过输入:设置你可以摆脱^ M crlf通过改变格式(:设置fileformat = unix),然后写出该文件。
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/
.)
如果你在中间有一个M,那么你应该能够看到它,即使是在fileformat=dos文件中,你也可以将它与\r匹配。(奇怪的是,subsituting换行符的语法\ r在替换子的一部分,所以一个M ^ ^ N变化是由not-at-all-a-noop:s / \ / \ r /)。
#2
55
Display CRLF as ^M:
:e ++ff=unix
:e + + ff = unix
Substitute CRLF for LF:
:setlocal ff=unix
:w
:e
:ff =对本地unix:w:e
#3
7
vim is autodetecting the fileformat and switching modes to match (take a look at set ff
)
vim是自动检测fileformat和切换模式以匹配(查看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.
如果您想强制它以特定的模式打开,那么在您的命令行中抛出一个+ff=unix(以显示M)或+ff=dos,以在该模式下打开它。如果您在windows框中,请尝试:在打开文件后,e ++ff=unix。
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.
如果您试图将这些字符删除,您可以在一个模式中打开它,将ff设置为您想要的,然后保存文件。查看:h ff了解更多细节。
#4
3
You can view all terminal linefeeds and carriage returns by enabling the list feature: :set list
.
您可以通过启用列表特性::set列表来查看所有的终端换行和回车。
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).
你可以输入他们字面匹配和替换命令^ V:例如转换所有女士^ CR,你能做的::% s / M V ^ ^ / CR / g(文字^ V型,后跟一个文字^ M)。
#1
51
Vim does show ^M except in one case: if the fileformat=dos then it will not show a trailing crlf.
Vim ^ M除了显示了一个例子:如果fileformat = dos末尾就不会显示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.
你可以找出哪些格式(unix或dos)你有通过输入:设置你可以摆脱^ M crlf通过改变格式(:设置fileformat = unix),然后写出该文件。
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/
.)
如果你在中间有一个M,那么你应该能够看到它,即使是在fileformat=dos文件中,你也可以将它与\r匹配。(奇怪的是,subsituting换行符的语法\ r在替换子的一部分,所以一个M ^ ^ N变化是由not-at-all-a-noop:s / \ / \ r /)。
#2
55
Display CRLF as ^M:
:e ++ff=unix
:e + + ff = unix
Substitute CRLF for LF:
:setlocal ff=unix
:w
:e
:ff =对本地unix:w:e
#3
7
vim is autodetecting the fileformat and switching modes to match (take a look at set ff
)
vim是自动检测fileformat和切换模式以匹配(查看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.
如果您想强制它以特定的模式打开,那么在您的命令行中抛出一个+ff=unix(以显示M)或+ff=dos,以在该模式下打开它。如果您在windows框中,请尝试:在打开文件后,e ++ff=unix。
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.
如果您试图将这些字符删除,您可以在一个模式中打开它,将ff设置为您想要的,然后保存文件。查看:h ff了解更多细节。
#4
3
You can view all terminal linefeeds and carriage returns by enabling the list feature: :set list
.
您可以通过启用列表特性::set列表来查看所有的终端换行和回车。
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).
你可以输入他们字面匹配和替换命令^ V:例如转换所有女士^ CR,你能做的::% s / M V ^ ^ / CR / g(文字^ V型,后跟一个文字^ M)。