Sunday, July 13, 2014

Re: how to hidden the ^M without change the file

On 2014-07-14 09:21, fengidri wrote:
> when the file has '\r\n' and '\n', I donot want see the ^M, but I
> donot want change the file.

There are a couple things:

1) Vim usually auto-detects the "\r\n" line endings if *all* the
lines have them. If some are missing the "\r" portion, you'll see
the ^M characters at the end of the line. To remedy this, I'd be
tempted to do the following:

vim mixed.txt
:%s/\r$
:w ++ff=dos

which will ensure that every line ends in "\r\n". Once the file is in
DOS line-ending format, you shouldn't see them unless you have
*redundant* line-endings ("\r\r\n"). This does technically change
the file (which you say you don't want to do) but it ensures that
EVERY line has "\r\n".

2) If you really are crazy and *do* want mixed line-endings (some with
"\r\n" and some with just "\n") then you can hide them with

:hi SpecialKey ctermfg=0 guifg=bg

where the values are whatever is output by

:hi Ignore

This does have some collateral damage where other embedded control
characters will be hidden (i.e., black-on-black or the like). The ^M
characters are still there, just hidden.

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: