Why does Vim on windows use \n for searching?

后端 未结 2 1496
旧时难觅i
旧时难觅i 2021-02-05 22:32

So I was changing code from

foo()
{

to

foo() {

and I noticed that the searching pattern required me to searc

2条回答
  •  情话喂你
    2021-02-05 23:02

    I think your problem is due to the fact that Unix-like operating systems like Linux use the newline (aka "linefeed") (0x0A) as the end of line marker, but Windows uses carriage return + newline (0x0D 0x0A). vim is trying to do some sort of mapping to make the Windows two-byte end of line look like a single "end of line".

    In a related note, the following command seems to convert a Unix-style file to a Windows one on a Windows machine, and convert a Windows-style file to a Unix one on a Unix machine:

    :%s/^V^M/^V^M/g

    where ^V means hold the control key and press the V, and similarly ^M means hold the control key and press M.

提交回复
热议问题