Vim: \n vs. \r

后端 未结 8 1122
小鲜肉
小鲜肉 2020-12-23 17:40

I haven\'t used vim in a Unix system in a while, but as I recall there was no \\r, it was always \\n.

I\'m using gVim under windows and when I search for new

8条回答
  •  自闭症患者
    2020-12-23 17:59

    Looks like you're asking two things. One issue is \r vs. \n which others have covered.

    The other issue is \n on the right side of a substitution. If you look at :h s/\n, it says that \n in the replacement part of a substitution inserts a / , NOT a newline.

    If you do a :%s/\n/\n/ and save and open the file in a hex editor, all the ^@ characters are ASCII 0's (NUL characters). Why the Vim devs use \n on the left for end-of-line and \n on the right for NUL is beyond me. But this particular behavior has nothing to do with Windows vs. Unix.

提交回复
热议问题