如何让vim显示^M并替换它 [英] how to make vim show ^M and substitute it

查看:280
本文介绍了如何让vim显示^M并替换它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 vim 将 tab 显示为 --->,但不显示 windows ^M 字符.

以及,如何在 vim 中替换它.

续订 ============

我检查了我的 vimrc,它被设置为 fileformat=unix但是当我打开一个 dos 文件集 ff 是 dos

解决方案

Vim 确实会显示 ^M,除了一种情况:如果 fileformat=dos 那么它不会显示尾随的 crlf.

您可以通过键入 :set 找出您拥有哪种格式(unix 或 dos),并且您只需更改格式 (:set) 即可摆脱 crlf 中的 ^Mfileformat=unix) 然后写出文件.

如果行中间有一个 ^M,那么即使在 fileformat=dos 文件中,您也应该能够看到它,并且您可以将它与 进行模式匹配\r.(奇怪的是,替换换行符的语法是 sub 替换部分中的 \r,因此将 ^M 更改为 ^N 的方法是通过 not-at-all-a-noop:s/\r/\r/.)

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 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/.)

这篇关于如何让vim显示^M并替换它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆